mirror-linux/drivers/gpu/drm/amd/amdkfd
Srinivasan Shanmugam 429aec2bc0 drm/amdkfd: Fix NULL pointer check order in kfd_ioctl_create_process
In kfd_ioctl_create_process(), the pointer 'p' is used before checking
if it is NULL.

The code accesses p->context_id before validating 'p'. This can lead
to a possible NULL pointer dereference.

Move the NULL check before using 'p' so that the pointer is validated
before access.

Fixes the below:
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_chardev.c:3177 kfd_ioctl_create_process() warn: variable dereferenced before check 'p' (see line 3174)

Fixes: cc6b66d661 ("amdkfd: introduce new ioctl AMDKFD_IOC_CREATE_PROCESS")
Cc: Zhu Lingshan <lingshan.zhu@amd.com>
Cc: Felix Kuehling <felix.kuehling@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 19d4149b22)
2026-03-24 13:54:19 -04:00
..
Kconfig drm/amdkfd: enable kfd on LoongArch systems 2025-07-15 14:07:50 -04:00
Makefile drm/amdkfd: Add interrupt handling for GFX 12.1.0 2025-12-08 14:13:11 -05:00
cik_event_interrupt.c drm/amdkfd: Identical code for different branches 2025-05-29 10:56:54 -04:00
cik_int.h
cik_regs.h
cwsr_trap_handler.h drm/amdkfd: gfx12.1 trap handler instruction fixup for VOP3PX 2026-01-28 16:21:21 -05:00
cwsr_trap_handler_gfx8.asm
cwsr_trap_handler_gfx9.asm drm/amdkfd: Clear MODE.VSKIP in gfx9 trap handler 2025-01-24 09:53:05 -05:00
cwsr_trap_handler_gfx10.asm drm/amdkfd: Move gfx12 trap handler to separate file 2025-01-09 16:02:56 -05:00
cwsr_trap_handler_gfx12.asm drm/amdkfd: gfx12.1 trap handler instruction fixup for VOP3PX 2026-01-28 16:21:21 -05:00
kfd_chardev.c drm/amdkfd: Fix NULL pointer check order in kfd_ioctl_create_process 2026-03-24 13:54:19 -04:00
kfd_crat.c drm/amdkfd: Check for NULL return values 2026-02-19 12:16:11 -05:00
kfd_crat.h
kfd_debug.c drm/amdkfd: Check for NULL return values 2026-02-19 12:16:11 -05:00
kfd_debug.h drm/amdkfd: fix gfx11 restrictions on debugging cooperative launch 2026-01-20 21:50:12 -05:00
kfd_debugfs.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_device.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_device_queue_manager.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_device_queue_manager.h drm/amdkfd: Add MQD manager for GFX 12.1.0 2025-12-08 14:13:08 -05:00
kfd_device_queue_manager_cik.c drm/amdkfd: Add support for more per-process flag 2025-03-07 15:33:49 -05:00
kfd_device_queue_manager_v9.c drm/amdkfd: Correct F8_MODE for gfx950 2025-03-13 23:13:12 -04:00
kfd_device_queue_manager_v10.c drm/amdkfd: Add support for more per-process flag 2025-03-07 15:33:49 -05:00
kfd_device_queue_manager_v11.c drm/amdkfd: Add support for more per-process flag 2025-03-07 15:33:49 -05:00
kfd_device_queue_manager_v12.c drm/amdkfd: Add support for more per-process flag 2025-03-07 15:33:49 -05:00
kfd_device_queue_manager_v12_1.c drm/amdgpu: Update MES VM_CNTX_CNTL for XNACK off for GFX 12.1 2025-12-10 17:39:09 -05:00
kfd_device_queue_manager_vi.c drm/amdkfd: Add support for more per-process flag 2025-03-07 15:33:49 -05:00
kfd_doorbell.c
kfd_events.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
kfd_events.h
kfd_flat_memory.c drm/amdkfd: Switch to using GC VERSION to decide LDS/Scratch base 2026-01-14 14:28:58 -05:00
kfd_int_process_v9.c drm/amdgpu: Add poison consumption sequence numbers for gfx and sdma 2025-10-20 18:18:47 -04:00
kfd_int_process_v10.c drm/amdkfd: drop warning in event_interrupt_isr_v1*() 2025-05-13 09:34:09 -04:00
kfd_int_process_v11.c drm/amdkfd: drop warning in event_interrupt_isr_v1*() 2025-05-13 09:34:09 -04:00
kfd_int_process_v12_1.c drm/amdkfd: Add interrupt handling for GFX 12.1.0 2025-12-08 14:13:11 -05:00
kfd_interrupt.c drm/amdgpu: Show warning message if IH ring overflow 2024-12-18 12:39:07 -05:00
kfd_kernel_queue.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_kernel_queue.h
kfd_migrate.c drm for 7.0-rc1 2026-02-11 12:55:44 -08:00
kfd_migrate.h drm/amdgpu: update the functions to use amdgpu version of hmm 2025-10-13 14:14:36 -04:00
kfd_module.c drm/amdkfd: Destroy KFD debugfs after destroy KFD wq 2025-08-06 16:52:08 -04:00
kfd_mqd_manager.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_mqd_manager.h drm/amdkfd: Adjust parameter of allocate_mqd 2026-01-29 12:26:58 -05:00
kfd_mqd_manager_cik.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_mqd_manager_v9.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_mqd_manager_v10.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_mqd_manager_v11.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_mqd_manager_v12.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_mqd_manager_v12_1.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_mqd_manager_vi.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_packet_manager.c drm/amdkfd: Support chain runlists of XNACK+/XNACK- 2025-05-16 13:37:29 -04:00
kfd_packet_manager_v9.c amdkfd: remove DIQ support 2025-12-08 13:56:42 -05:00
kfd_packet_manager_vi.c amdkfd: remove DIQ support 2025-12-08 13:56:42 -05:00
kfd_pm4_headers.h
kfd_pm4_headers_ai.h drm/amdkfd: Support chain runlists of XNACK+/XNACK- 2025-05-16 13:37:29 -04:00
kfd_pm4_headers_aldebaran.h
kfd_pm4_headers_vi.h
kfd_pm4_opcodes.h
kfd_priv.h Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_process.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
kfd_process_queue_manager.c drm/amdkfd: Unreserve bo if queue update failed 2026-03-11 14:02:45 -04:00
kfd_queue.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_smi_events.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_smi_events.h drm/amdkfd: add smi events for process start and end 2025-04-11 17:01:25 -04:00
kfd_svm.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_svm.h drm/amdgpu: update the functions to use amdgpu version of hmm 2025-10-13 14:14:36 -04:00
kfd_topology.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
kfd_topology.h drm/amdgpu: reduce the full gpu access time in amdgpu_device_init. 2025-12-08 13:56:38 -05:00
soc15_int.h