The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drm/nouveau/gsp: Use kzalloc_flex() for r535 display funcs
@ 2026-05-08  5:20 Rosen Penev
  2026-05-08 18:54 ` lyude
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-05-08  5:20 UTC (permalink / raw)
  To: nouveau
  Cc: Lyude Paul, Danilo Krummrich, Maarten Lankhorst, Maxime Ripard,
	Thomas Zimmermann, David Airlie, Simona Vetter,
	open list:DRM DRIVER FOR NVIDIA GEFORCE/QUADRO GPUS, open list

struct nvkm_disp_func ends with the user flexible array member. Allocate the
r535 display function table with kzalloc_flex() instead of open-coding the
size calculation with sizeof().

This makes the allocation describe the object being allocated directly and
keeps the fixed six user entries unchanged.

Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
index 6e63df816d85..1155f079b0c3 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
@@ -1734,7 +1734,8 @@ r535_disp_new(const struct nvkm_disp_func *hw, struct nvkm_device *device,
 	struct nvkm_disp_func *rm;
 	int ret;
 
-	if (!(rm = kzalloc(sizeof(*rm) + 6 * sizeof(rm->user[0]), GFP_KERNEL)))
+	rm = kzalloc_flex(*rm, user, 6);
+	if (!rm)
 		return -ENOMEM;
 
 	rm->dtor = r535_disp_dtor;
-- 
2.54.0


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

end of thread, other threads:[~2026-05-08 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08  5:20 [PATCH] drm/nouveau/gsp: Use kzalloc_flex() for r535 display funcs Rosen Penev
2026-05-08 18:54 ` lyude

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