diff options
author | Sergey Shtylyov <s.shtylyov@omp.ru> | 2022-02-08 15:02:15 +0300 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2022-02-28 13:06:23 +0100 |
commit | f5d8a5fe77ce933f53eb8f2e22bb7a1a2019ea11 (patch) | |
tree | b181f678859b9d19372e69c3673993c0e434974c /drivers/mmc/core/sdio.c | |
parent | mmc: sunxi-mmc: Add D1 MMC variant (diff) | |
download | linux-dev-f5d8a5fe77ce933f53eb8f2e22bb7a1a2019ea11.tar.xz linux-dev-f5d8a5fe77ce933f53eb8f2e22bb7a1a2019ea11.zip |
mmc: core: use sysfs_emit() instead of sprintf()
sprintf() (still used in the MMC core for the sysfs output) is vulnerable
to the buffer overflow. Use the new-fangled sysfs_emit() instead.
Found by Linux Verification Center (linuxtesting.org) with the SVACE static
analysis tool.
Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/717729b2-d65b-c72e-9fac-471d28d00b5a@omp.ru
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/core/sdio.c')
-rw-r--r-- | drivers/mmc/core/sdio.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 41164748723d..25799accf8a0 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c @@ -7,6 +7,7 @@ #include <linux/err.h> #include <linux/pm_runtime.h> +#include <linux/sysfs.h> #include <linux/mmc/host.h> #include <linux/mmc/card.h> @@ -40,9 +41,9 @@ static ssize_t info##num##_show(struct device *dev, struct device_attribute *att \ if (num > card->num_info) \ return -ENODATA; \ - if (!card->info[num-1][0]) \ + if (!card->info[num - 1][0]) \ return 0; \ - return sprintf(buf, "%s\n", card->info[num-1]); \ + return sysfs_emit(buf, "%s\n", card->info[num - 1]); \ } \ static DEVICE_ATTR_RO(info##num) |