[PATCH 04/18] nouveau: change strncpy+truncation to strlcpy

From: Dominique Martinet
Date: Thu Jul 12 2018 - 21:25:23 EST


Generated by scripts/coccinelle/misc/strncpy_truncation.cocci

Signed-off-by: Dominique Martinet <asmadeus@xxxxxxxxxxxxx>
---

Please see https://marc.info/?l=linux-kernel&m=153144450722324&w=2 (the
first patch of the serie) for the motivation behind this patch

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 058ff46b5f16..579eb17db9f4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
+++ b/drivers/gpu/drm/nouveau/nvkm/core/firmware.c
@@ -40,8 +40,7 @@ nvkm_firmware_get(struct nvkm_device *device, const char *fwname,
int i;

/* Convert device name to lowercase */
- strncpy(cname, device->chip->name, sizeof(cname));
- cname[sizeof(cname) - 1] = '\0';
+ strlcpy(cname, device->chip->name, sizeof(cname));
i = strlen(cname);
while (i) {
--i;
--
2.17.1