Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef3868b6 authored by Xiaoyu Ye's avatar Xiaoyu Ye Committed by Gerrit - the friendly Code Review server
Browse files

ASoC: msm-cpe: Fix range checking in function fw_name_store



The range checking between "WCD_CPE_IMAGE_FNAME_MAX" and
"copy_count" is off-by-one due to the size of array
"core->dyn_fname" is "WCD_CPE_IMAGE_FNAME_MAX". Subtract
one from the range checking to fix this issue.

Change-Id: I87fd55206f79ad7b13c3878f6642bf5579303b17
Signed-off-by: default avatarXiaoyu Ye <benyxy@codeaurora.org>
parent b81d100b
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1731,10 +1731,10 @@ static ssize_t fw_name_store(struct wcd_cpe_core *core,
	if (pos)
		copy_count = pos - buf;

	if (copy_count > WCD_CPE_IMAGE_FNAME_MAX) {
	if (copy_count > (WCD_CPE_IMAGE_FNAME_MAX - 1)) {
		dev_err(core->dev,
			"%s: Invalid length %d, max allowed %d\n",
			__func__, copy_count, WCD_CPE_IMAGE_FNAME_MAX);
			__func__, copy_count, WCD_CPE_IMAGE_FNAME_MAX - 1);
		return -EINVAL;
	}