Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b4df2047 authored by Dan Carpenter's avatar Dan Carpenter Committed by Tomi Valkeinen
Browse files

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: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarTomi Valkeinen <tomi.valkeinen@ti.com>
parent b06ece93
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -485,7 +485,7 @@ static ssize_t show_bl_curve(struct device *device,

	mutex_lock(&fb_info->bl_curve_mutex);
	for (i = 0; i < FB_BACKLIGHT_LEVELS; i += 8)
		len += snprintf(&buf[len], PAGE_SIZE, "%8ph\n",
		len += scnprintf(&buf[len], PAGE_SIZE - len, "%8ph\n",
				fb_info->bl_curve + i);
	mutex_unlock(&fb_info->bl_curve_mutex);