]> git.ipfire.org Git - thirdparty/linux.git/commit
fbdev: bound mode sysfs output to the sysfs buffer
authorMelbin K Mathew <mlbnkm1@gmail.com>
Wed, 1 Jul 2026 23:42:46 +0000 (01:42 +0200)
committerHelge Deller <deller@gmx.de>
Sat, 8 Aug 2026 06:08:58 +0000 (08:08 +0200)
commitd15d51fb26e830af58f3f21964f1c09c239077ea
tree531cd5c2d0dfce25186e977350bbfd67b1eccc53
parent075b74841bd0065a3bda3440873c747938e69b68
fbdev: bound mode sysfs output to the sysfs buffer

mode_string() uses snprintf() which can return a value larger than the
remaining buffer space. show_modes() accumulates the return value into i
without checking whether i has reached PAGE_SIZE, causing the offset to
advance past the sysfs buffer if the modelist is long enough.

Add a size parameter to mode_string() and use scnprintf() to return
only the bytes actually written. Add an early return when offset
already exceeds the buffer. In show_modes(), stop accumulating once
the buffer is full.

Cc: stable@vger.kernel.org # v7.1+
Signed-off-by: Melbin K Mathew <mlbnkm1@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/core/fbsysfs.c