diff mbox series

mmc: core: sdio_bus: use sysfs_emit() in #define sdio_config_attr()

Message ID ff012dc6-9f54-9546-3d2f-ee6f95e0665b@omp.ru (mailing list archive)
State New, archived
Headers show
Series mmc: core: sdio_bus: use sysfs_emit() in #define sdio_config_attr() | expand

Commit Message

Sergey Shtylyov Jan. 28, 2022, 4:47 p.m. UTC
sprintf() (still used in #define sdio_config_attr()) 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>

---
This patch is against the 'next' branch of Ulf Hansson's 'mmc.git' repo.
---
 drivers/mmc/core/sdio_bus.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

Index: mmc/drivers/mmc/core/sdio_bus.c
===================================================================
--- mmc.orig/drivers/mmc/core/sdio_bus.c
+++ mmc/drivers/mmc/core/sdio_bus.c
@@ -35,7 +35,7 @@  field##_show(struct device *dev, struct
 	struct sdio_func *func;						\
 									\
 	func = dev_to_sdio_func (dev);					\
-	return sprintf(buf, format_string, args);			\
+	return sysfs_emit(buf, format_string, args);			\
 }									\
 static DEVICE_ATTR_RO(field)