Re: [PATCH v3 1/3] fbdev: bound mode sysfs output to the sysfs buffer

From: Helge Deller

Date: Sat Jul 18 2026 - 16:05:07 EST


On 7/2/26 01:42, Melbin K Mathew wrote:
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@xxxxxxxxxxxxxxx
Signed-off-by: Melbin K Mathew <mlbnkm1@xxxxxxxxx>
---
drivers/video/fbdev/core/fbsysfs.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
I've applied the series to fbdev git tree for further testing.

Thanks!
Helge