Skip to contentSkip to conversation

gpu/drm/nouveau/nvif: fix a null dereference in nvif_client_ctor()

PATCH In review Alexandr Sapozhnkiov 2 participants 2 messages Oct 2, 2025 – Oct 3, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu/drm/nouveau/nvif: fix a null dereference in nvif_client_ctor()

From: Alexandr Sapozhnikov <[email protected]>

If the name parameter can be NULL, then you should not do strncpy before checking name for NULL.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

---
 drivers/gpu/drm/nouveau/nvif/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nvif/client.c +1 -1
index 3a27245f467f..3cfe420b5156 100644
@@ -69,7 +69,7 @@ nvif_client_ctor(struct nvif_client *parent, const char *name, u64 device,
 	} nop = {};
 	int ret;
 
-	strscpy_pad(args.name, name, sizeof(args.name));
+	strscpy_pad(args.name, name ? name : "nvifClient", sizeof(args.name));
 	ret = nvif_object_ctor(parent != client ? &parent->object : NULL,
 			       name ? name : "nvifClient", 0,
 			       NVIF_CLASS_CLIENT, &args, sizeof(args),
Signature · 1 line
2.43.0