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

fbdev: fix snprintf() limit in show_bl_curve()

The limit should be "PAGE_SIZE - len" instead of PAGE_SIZE. Also let's
use scnprintf() because snprintf() returns the number of bytes which
would have been printed if there were space and scnprintf() returns the
number of bytes actually printed.

I don't think we are ever going to actually hit this limit in real life.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>

authored by

Dan Carpenter and committed by
Tomi Valkeinen
b4df2047 b06ece93

+1 -1
+1 -1
drivers/video/fbdev/core/fbsysfs.c
··· 485 485 486 486 mutex_lock(&fb_info->bl_curve_mutex); 487 487 for (i = 0; i < FB_BACKLIGHT_LEVELS; i += 8) 488 - len += snprintf(&buf[len], PAGE_SIZE, "%8ph\n", 488 + len += scnprintf(&buf[len], PAGE_SIZE - len, "%8ph\n", 489 489 fb_info->bl_curve + i); 490 490 mutex_unlock(&fb_info->bl_curve_mutex); 491 491