From 0c53b526c049c1e8bc1048b5ed8f80996e4a4be6 Mon Sep 17 00:00:00 2001 From: Xiaoyu Ye Date: Fri, 12 May 2017 16:09:01 -0700 Subject: 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: Xiaoyu Ye --- sound/soc/codecs/wcd_cpe_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wcd_cpe_core.c b/sound/soc/codecs/wcd_cpe_core.c index 3b681f53b17a..9218786f913f 100644 --- a/sound/soc/codecs/wcd_cpe_core.c +++ b/sound/soc/codecs/wcd_cpe_core.c @@ -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; } -- cgit v1.2.3