Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: mtdpart: Convert sysfs sprintf/snprintf family to sysfs_emit

Use sysfs_emit instead of snprintf to avoid buf overrun,because in
sysfs_emit it strictly checks whether buf is null or buf whether
pagesize aligned, otherwise it returns an error.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1618220144-33839-3-git-send-email-tiantao6@hisilicon.com

authored by

Tian Tao and committed by
Miquel Raynal
ce675043 5b2fbe0c

+1 -1
+1 -1
drivers/mtd/mtdpart.c
··· 217 217 { 218 218 struct mtd_info *mtd = dev_get_drvdata(dev); 219 219 220 - return snprintf(buf, PAGE_SIZE, "%lld\n", mtd->part.offset); 220 + return sysfs_emit(buf, "%lld\n", mtd->part.offset); 221 221 } 222 222 223 223 static DEVICE_ATTR(offset, S_IRUGO, mtd_partition_offset_show, NULL);