summaryrefslogtreecommitdiffstats
path: root/drivers/mmc/core/bus.h
diff options
context:
space:
mode:
authorSergey Shtylyov <s.shtylyov@omp.ru>2022-02-08 15:02:15 +0300
committerUlf Hansson <ulf.hansson@linaro.org>2022-02-28 13:06:23 +0100
commitf5d8a5fe77ce933f53eb8f2e22bb7a1a2019ea11 (patch)
treeb181f678859b9d19372e69c3673993c0e434974c /drivers/mmc/core/bus.h
parent75a2f412d0aed4a4a80ab2a2d96d040b17acb6d6 (diff)
downloadlinux-f5d8a5fe77ce933f53eb8f2e22bb7a1a2019ea11.tar.bz2
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/bus.h')
-rw-r--r--drivers/mmc/core/bus.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/mmc/core/bus.h b/drivers/mmc/core/bus.h
index 8105852c4b62..3996b191b68d 100644
--- a/drivers/mmc/core/bus.h
+++ b/drivers/mmc/core/bus.h
@@ -9,6 +9,7 @@
#define _MMC_CORE_BUS_H
#include <linux/device.h>
+#include <linux/sysfs.h>
struct mmc_host;
struct mmc_card;
@@ -17,7 +18,7 @@ struct mmc_card;
static ssize_t mmc_##name##_show (struct device *dev, struct device_attribute *attr, char *buf) \
{ \
struct mmc_card *card = mmc_dev_to_card(dev); \
- return sprintf(buf, fmt, args); \
+ return sysfs_emit(buf, fmt, args); \
} \
static DEVICE_ATTR(name, S_IRUGO, mmc_##name##_show, NULL)