]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/nouveau/gsp: Use kzalloc_flex() for r535 display funcs
authorRosen Penev <rosenp@gmail.com>
Fri, 8 May 2026 05:20:56 +0000 (22:20 -0700)
committerLyude Paul <lyude@redhat.com>
Fri, 8 May 2026 18:55:35 +0000 (14:55 -0400)
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().

Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
[dropped nothing-burger sentence from commit message]
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://patch.msgid.link/20260508052056.1744665-1-rosenp@gmail.com
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c

index 6e63df816d8557c0514a21ad1fe992570bb3b799..1155f079b0c3de9b34353ca87f912b0508fa470e 100644 (file)
@@ -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;