From: Seokju Yoon Date: Wed, 7 Dec 2016 04:19:12 +0000 (+0900) Subject: [COMMON] bcm: fix stack overflow possibility. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=01db5725173f8d22d505308743269749fffe01e5;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [COMMON] bcm: fix stack overflow possibility. Change-Id: Ia87174a7f0f04dfaf2e03935f66348ec1119d50b Signed-off-by: Seokju Yoon --- diff --git a/drivers/soc/samsung/exynos-bcm.c b/drivers/soc/samsung/exynos-bcm.c index 3d60a0462141..93d9983cf98d 100644 --- a/drivers/soc/samsung/exynos-bcm.c +++ b/drivers/soc/samsung/exynos-bcm.c @@ -410,17 +410,16 @@ static ssize_t store_load_bcm_fw(struct device *dev, unsigned long flags; int ret; bool value = true; - char str[FILE_STR]; - ret = sscanf(buf, "%s", str); - if (ret != 1) { - dev_err(dev, "failed sscanf %d\n", ret); - return -EINVAL; - } - if (str[0] == '0') + if (buf[0] == '0') { value = false; - else if (str[0] == '/') - strncpy(input_file, str, strlen(str) + 1); + } else if (buf[0] == '/' && strlen(buf) < FILE_STR) { + ret = sscanf(buf, "%s", input_file); + if (ret != 1) { + dev_err(dev, "failed sscanf %d\n", ret); + return -EINVAL; + } + } /* bcm stop and pd unprepare */ if (fw_func) {