]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu/atom: Check kcalloc() for WS buffer in amdgpu_atom_execute_table_locked()
authorGuangshuo Li <lgs201920130244@gmail.com>
Thu, 18 Sep 2025 10:57:05 +0000 (18:57 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 18 Sep 2025 20:59:27 +0000 (16:59 -0400)
kcalloc() may fail. When WS is non-zero and allocation fails, ectx.ws
remains NULL while ectx.ws_size is set, leading to a potential NULL
pointer dereference in atom_get_src_int() when accessing WS entries.

Return -ENOMEM on allocation failure to avoid the NULL dereference.

Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/atom.c

index 1c994d0cc50b54567b61ce450903da0c40217006..be5d67c2c7a15892af4f12bc513a8ce8c8dd91cb 100644 (file)
@@ -1246,6 +1246,10 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index,
        ectx.last_jump_jiffies = 0;
        if (ws) {
                ectx.ws = kcalloc(4, ws, GFP_KERNEL);
+               if (!ectx.ws) {
+                       ret = -ENOMEM;
+                       goto free;
+               }
                ectx.ws_size = ws;
        } else {
                ectx.ws = NULL;