mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 04:40:09 +01:00
This commit adds essential parameter validation to several key functions in amdgpu_bo.c to prevent null pointer dereferences that were causing segmentation faults and improve overall code robustness. The changes address the following crash scenario: Received signal SIGSEGV. Stack trace: #0 [fatal_sig_handler+0x17b] #1 [__sigaction+0x50] #2 [amdgpu_bo_alloc+0x37] #3 [__igt_unique____real_main461+0x7d5] #4 [main+0x2d] #5 [__libc_init_first+0x90] #6 [__libc_start_main+0x80] #7 [_start+0x25] Changes made: 1. amdgpu_bo_alloc(): - Validate alloc_buffer and buf_handle parameters - Return -EINVAL if either is NULL - Prevents null pointer dereference in memset and subsequent operations 2. amdgpu_bo_set_metadata(): - Validate info parameter - Return -EINVAL if info is NULL - Prevents accessing invalid metadata structure 3. amdgpu_bo_query_info(): - Validate info parameter in addition to existing bo->handle check - Return -EINVAL if info is NULL - Prevents writing to invalid info pointer 4. amdgpu_bo_list_create(): - Validate resources parameter - Return -EINVAL if resources is NULL when number_of_resources > 0 - Prevents invalid memory access during resource array processing These changes ensure proper error handling when callers pass invalid null pointers, preventing potential segmentation faults and making the API more robust against programming errors. The validation occurs early in each function to minimize performance impact. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Jesse Zhang <Jesse.Zhang@amd.com> |
||
|---|---|---|
| .. | ||
| .editorconfig | ||
| amdgpu-symbols.txt | ||
| amdgpu.h | ||
| amdgpu_asic_id.c | ||
| amdgpu_bo.c | ||
| amdgpu_cs.c | ||
| amdgpu_device.c | ||
| amdgpu_gpu_info.c | ||
| amdgpu_internal.h | ||
| amdgpu_userq.c | ||
| amdgpu_vamgr.c | ||
| amdgpu_vm.c | ||
| Android.bp | ||
| Android.sources.bp | ||
| handle_table.c | ||
| handle_table.h | ||
| libdrm_amdgpu.pc.in | ||
| meson.build | ||