mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: fbtft: use scnprintf for fixed-size text buffers
@ 2026-10-21  3:22 LiuJunyuan
  2026-10-21  5:59 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: LiuJunyuan @ 2026-10-21  3:22 UTC (permalink / raw)
  To: andy
  Cc: gregkh, dri-devel, linux-fbdev, linux-staging, linux-kernel, LiuJunyuan

Replace sprintf() with scnprintf() when formatting the framebuffer
description strings into fixed-size buffers.

Signed-off-by: LiuJunyuan <2058432396@qq.com>
---
 drivers/staging/fbtft/fbtft-core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 7925d974de80..f7751b972a52 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -785,10 +785,12 @@ int fbtft_register_framebuffer(struct fb_info *fb_info)
 	fbtft_sysfs_init(par);
 
 	if (par->txbuf.buf && par->txbuf.len >= 1024)
-		sprintf(text1, ", %zu KiB buffer memory", par->txbuf.len >> 10);
+		scnprintf(text1, sizeof(text1), ", %zu KiB buffer memory",
+			  par->txbuf.len >> 10);
 	if (spi)
-		sprintf(text2, ", spi%d.%d at %d MHz", spi->controller->bus_num,
-			spi_get_chipselect(spi, 0), spi->max_speed_hz / 1000000);
+		scnprintf(text2, sizeof(text2), ", spi%d.%d at %d MHz",
+			  spi->controller->bus_num, spi_get_chipselect(spi, 0),
+			  spi->max_speed_hz / 1000000);
 	fb_dbg(fb_info,
 	       "%s frame buffer, %dx%d, %d KiB video memory%s, fps=%lu%s\n",
 	       fb_info->fix.id, fb_info->var.xres, fb_info->var.yres,
-- 
2.43.0


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

* Re: [PATCH] staging: fbtft: use scnprintf for fixed-size text buffers
  2026-10-21  3:22 [PATCH] staging: fbtft: use scnprintf for fixed-size text buffers LiuJunyuan
@ 2026-10-21  5:59 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2026-10-21  5:59 UTC (permalink / raw)
  To: LiuJunyuan
  Cc: andy, gregkh, dri-devel, linux-fbdev, linux-staging, linux-kernel

On Wed, Oct 21, 2026 at 11:22:08AM +0800, LiuJunyuan wrote:
> Replace sprintf() with scnprintf() when formatting the framebuffer
> description strings into fixed-size buffers.

In commits like this, I want some analysis of if this change matters
or not.  I would still support a change like this even if it didn't
fix a bug but the commit message needs to say if it's a cleanup or
a fix.

regards,
dan carpenter


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

end of thread, other threads:[~2026-10-21  5:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-21  3:22 [PATCH] staging: fbtft: use scnprintf for fixed-size text buffers LiuJunyuan
2026-10-21  5:59 ` Dan Carpenter

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

all inboxes | Powered by JetHome®