Linux Framebuffer Layer development
 help / color / mirror / Atom feed
* [PATCH] staging: fbtft: Use sysfs_emit_at() to print to sysfs file
@ 2026-06-03  7:34 Dan Carpenter
  2026-06-03  7:49 ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2026-06-03  7:34 UTC (permalink / raw)
  To: Thomas Petazzoni
  Cc: Andy Shevchenko, Greg Kroah-Hartman, Helge Deller,
	Thomas Zimmermann, Chintan Patel, dri-devel, linux-fbdev,
	linux-staging, linux-kernel, kernel-janitors

This scnprintf() uses the wrong limit.  It should be "PAGE_SIZE - len"
instead of just PAGE_SIZE.  We're not going to hit the limit in real
life since we are printing at most FBTFT_GAMMA_MAX_VALUES_TOTAL (128)
u32 values, however, it's still worth fixing.

Use sysfs_emit_at() to fix this since this is a sysfs file.

Fixes: c296d5f9957c ("staging: fbtft: core support")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
 drivers/staging/fbtft/fbtft-sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fbtft-sysfs.c b/drivers/staging/fbtft/fbtft-sysfs.c
index d05599d80011..343545e83a37 100644
--- a/drivers/staging/fbtft/fbtft-sysfs.c
+++ b/drivers/staging/fbtft/fbtft-sysfs.c
@@ -98,7 +98,7 @@ sprintf_gamma(struct fbtft_par *par, u32 *curves, char *buf)
 	mutex_lock(&par->gamma.lock);
 	for (i = 0; i < par->gamma.num_curves; i++) {
 		for (j = 0; j < par->gamma.num_values; j++)
-			len += scnprintf(&buf[len], PAGE_SIZE,
+			len += sysfs_emit_at(buf, len,
 			     "%04x ", curves[i * par->gamma.num_values + j]);
 		buf[len - 1] = '\n';
 	}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-03 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-03  7:34 [PATCH] staging: fbtft: Use sysfs_emit_at() to print to sysfs file Dan Carpenter
2026-06-03  7:49 ` Andy Shevchenko
2026-06-03 12:48   ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox