[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202212070911086649831@zte.com.cn>
Date: Wed, 7 Dec 2022 09:11:08 +0800 (CST)
From: <yang.yang29@....com.cn>
To: <bskeggs@...hat.com>
Cc: <kherbst@...hat.com>, <lyude@...hat.com>, <airlied@...il.com>,
<daniel@...ll.ch>, <dri-devel@...ts.freedesktop.org>,
<nouveau@...ts.freedesktop.org>, <linux-kernel@...r.kernel.org>,
<xu.panda@....com.cn>, <yang.yang29@....com.cn>
Subject: [PATCH linux-next] drm/nouveau/nvkm/core/firmware: replace strncpy() with
strscpy()
From: Xu Panda <xu.panda@....com.cn>
The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL terminated strings.
Signed-off-by: Xu Panda <xu.panda@....com.cn>
Signed-off-by: Yang Yang <yang.yang29@....com>
---
drivers/gpu/drm/nouveau/nvkm/core/firmware.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
index fcf2a002f6cb..5554f907e0d4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
@@ -79,8 +79,7 @@ nvkm_firmware_get(const struct nvkm_subdev *subdev, const char *fwname, int ver,
int i;
/* Convert device name to lowercase */
- strncpy(cname, device->chip->name, sizeof(cname));
- cname[sizeof(cname) - 1] = '\0';
+ strscpy(cname, device->chip->name, sizeof(cname));
i = strlen(cname);
while (i) {
--i;
--
2.15.2
Powered by blists - more mailing lists