public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpu/drm/nouveau/nvif: fix a null dereference in nvif_client_ctor()
@ 2025-10-02  8:33 Alexandr Sapozhnkiov
  2025-10-03 15:50 ` Markus Elfring
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandr Sapozhnkiov @ 2025-10-02  8:33 UTC (permalink / raw)
  To: Karol Herbst, Lyude Paul, Danilo Krummrich, David Airlie,
	Daniel Vetter, dri-devel, nouveau, linux-kernel
  Cc: Alexandr Sapozhnikov, lvc-project

From: Alexandr Sapozhnikov <alsp705@gmail.com>

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.

Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
---
 drivers/gpu/drm/nouveau/nvif/client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvif/client.c b/drivers/gpu/drm/nouveau/nvif/client.c
index 3a27245f467f..3cfe420b5156 100644
--- a/drivers/gpu/drm/nouveau/nvif/client.c
+++ b/drivers/gpu/drm/nouveau/nvif/client.c
@@ -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),
-- 
2.43.0


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

* Re: [PATCH] gpu/drm/nouveau/nvif: fix a null dereference in nvif_client_ctor()
  2025-10-02  8:33 [PATCH] gpu/drm/nouveau/nvif: fix a null dereference in nvif_client_ctor() Alexandr Sapozhnkiov
@ 2025-10-03 15:50 ` Markus Elfring
  0 siblings, 0 replies; 2+ messages in thread
From: Markus Elfring @ 2025-10-03 15:50 UTC (permalink / raw)
  To: Alexandr Sapozhnikov, nouveau, dri-devel, lvc-project
  Cc: LKML, Daniel Vetter, Danilo Krummrich, David Airlie, Karol Herbst,
	Lyude Paul

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

Would a corresponding imperative wording become helpful for an improved change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17#n94

Regards,
Markus

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

end of thread, other threads:[~2025-10-03 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-02  8:33 [PATCH] gpu/drm/nouveau/nvif: fix a null dereference in nvif_client_ctor() Alexandr Sapozhnkiov
2025-10-03 15:50 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox