Patch to replace strcpy() with strscpy() in drm_fb_helper.c
Abanoub Sameh
abanoubsameh at protonmail.com
Wed Apr 23 07:12:05 UTC 2025
>From e45e4d9016262ace19db01e69d266d6218789ccd Mon Sep 17 00:00:00 2001
From: Abanoub Sameh <abanoubsameh at protonmail.com>
Date: Thu, 17 Apr 2025 23:37:21 +0200
Subject: [PATCH] Use strscpy() instead of strcpy() in
drivers/gpu/drm/drm_fb_helper.c
Use strscpy() instead of strcpy() since it is safer, and compliant with checkpatch.pl
It is an easy fix, since the size of fb_helper->fb->comm is a constant defined at linux/sched.h
strcpy() does not check for destination size and should not be used, see:
https://github.com/KSPP/linux/issues/88
Signed-off-by: Abanoub Sameh <abanoubsameh at protonmail.com>
---
drivers/gpu/drm/drm_fb_helper.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 937c3939e..4392aba01 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -33,6 +33,7 @@
#include <linux/pci.h>
#include <linux/sysrq.h>
#include <linux/vga_switcheroo.h>
+#include <linux/sched.h>
#include <drm/drm_atomic.h>
#include <drm/drm_drv.h>
@@ -1650,7 +1651,7 @@ static int drm_fb_helper_single_fb_probe(struct drm_fb_helper *fb_helper)
if (ret < 0)
return ret;
- strcpy(fb_helper->fb->comm, "[fbcon]");
+ strscpy(fb_helper->fb->comm, "[fbcon]", TASK_COMM_LEN);
info = fb_helper->info;
--
2.49.0
More information about the dri-devel
mailing list