Skip to content

Commit cc9a8e2

Browse files
lgs2513alexdeucher
authored andcommitted
drm/amdgpu/atom: Check kcalloc() for WS buffer in amdgpu_atom_execute_table_locked()
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 <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 59e4405 commit cc9a8e2

File tree

1 file changed

+4
-0
lines changed
  • drivers/gpu/drm/amd/amdgpu

1 file changed

+4
-0
lines changed

drivers/gpu/drm/amd/amdgpu/atom.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,6 +1246,10 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index,
12461246
ectx.last_jump_jiffies = 0;
12471247
if (ws) {
12481248
ectx.ws = kcalloc(4, ws, GFP_KERNEL);
1249+
if (!ectx.ws) {
1250+
ret = -ENOMEM;
1251+
goto free;
1252+
}
12491253
ectx.ws_size = ws;
12501254
} else {
12511255
ectx.ws = NULL;

0 commit comments

Comments
 (0)