From 01db5725173f8d22d505308743269749fffe01e5 Mon Sep 17 00:00:00 2001 From: Seokju Yoon Date: Wed, 7 Dec 2016 13:19:12 +0900 Subject: [PATCH] [COMMON] bcm: fix stack overflow possibility. Change-Id: Ia87174a7f0f04dfaf2e03935f66348ec1119d50b Signed-off-by: Seokju Yoon --- drivers/soc/samsung/exynos-bcm.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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) { -- 2.20.1