All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] video: fbdev: via: refactor strcpy and viafb_name
@ 2026-08-14  6:54 Ajith P V
  2026-08-14  7:01 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ajith P V @ 2026-08-14  6:54 UTC (permalink / raw)
  To: FlorianSchandinat, deller; +Cc: linux-fbdev, dri-devel, linux-kernel, Ajith P V

Replace the deprecated and unbounded strcpy() function with the safer
strscpy() alternative when setting up the framebuffer fixed screen
information [1][2].

It aligns this driver with the ongoing kernel-wide security initiative
to eliminate unbounded string copies, hardening the code against future
modifications.

Additionally, convert the file-scope `viafb_name` pointer into a
`static const char[]` array and update its value to "viafb".
This permits the compiler to execute compile-time bounds checking and
aggressively optimize the runtime string copy operation out entirely.

This is a proactive API cleanup and there is no functional performance
or truncation risk.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
Link: https://github.com/KSPP/linux/issues/88 [2]

Signed-off-by: Ajith P V <ajithpv.linux@gmail.com>
---
v2:
  - Keep variable static but change it to a const array 
    'static const char viafb_name[] = "viafb"' as suggested by Helge Deller 
    to let the compiler leverage compile-time checks.

 drivers/video/fbdev/via/viafbdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c
index 80f95dac32c8..b3a2e07b61a7 100644
--- a/drivers/video/fbdev/via/viafbdev.c
+++ b/drivers/video/fbdev/via/viafbdev.c
@@ -16,7 +16,7 @@
 #define _MASTER_FILE
 #include "global.h"
 
-static char *viafb_name = "Via";
+static const char viafb_name[] = "viafb";
 static u32 pseudo_pal[17];
 
 /* video mode */
@@ -144,7 +144,7 @@ static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
 	struct viafb_par *viaparinfo)
 {
 	memset(fix, 0, sizeof(struct fb_fix_screeninfo));
-	strcpy(fix->id, viafb_name);
+	strscpy(fix->id, viafb_name, sizeof(fix->id));
 
 	fix->smem_start = viaparinfo->fbmem;
 	fix->smem_len = viaparinfo->fbmem_free;
-- 
2.43.0


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

end of thread, other threads:[~2026-08-14  7:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-14  6:54 [PATCH v2] video: fbdev: via: refactor strcpy and viafb_name Ajith P V
2026-08-14  7:01 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.