[AMD Official Use Only - AMD Internal Distribution Only] Series is
Reviewed-by: YiPeng Chai <[email protected]> Best Regards, Thomas -----Original Message----- From: SHANMUGAM, SRINIVASAN <[email protected]> Sent: Thursday, March 19, 2026 1:48 PM To: Chai, Thomas <[email protected]>; Zhou1, Tao <[email protected]> Cc: [email protected]; SHANMUGAM, SRINIVASAN <[email protected]>; Dan Carpenter <[email protected]>; Koenig, Christian <[email protected]>; Deucher, Alexander <[email protected]> Subject: [PATCH 2/2] drm/amd/ras: Add NULL checks for ras_core sys_fn callbacks Some ras core helper functions access ras_core and its callback table (sys_fn) without validating them first. Cc: Tao Zhou <[email protected]> Cc: YiPeng Chai <[email protected]> Cc: Dan Carpenter <[email protected]> Cc: Christian König <[email protected]> Cc: Alex Deucher <[email protected]> Signed-off-by: Srinivasan Shanmugam <[email protected]> Change-Id: I2859a63a86a8f38585c98f7627fa1e19e83a17b0 --- drivers/gpu/drm/amd/ras/rascore/ras_core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_core.c b/drivers/gpu/drm/amd/ras/rascore/ras_core.c index 4e84220ef152..29b1b8f0cc26 100644 --- a/drivers/gpu/drm/amd/ras/rascore/ras_core.c +++ b/drivers/gpu/drm/amd/ras/rascore/ras_core.c @@ -119,6 +119,9 @@ bool ras_core_gpu_in_reset(struct ras_core_context *ras_core) { uint32_t status = 0; + if (!ras_core) + return false; + if (ras_core->sys_fn && ras_core->sys_fn->check_gpu_status) ras_core->sys_fn->check_gpu_status(ras_core, &status); @@ -130,6 +133,9 @@ bool ras_core_gpu_is_vf(struct ras_core_context *ras_core) { uint32_t status = 0; + if (!ras_core) + return false; + if (ras_core->sys_fn && ras_core->sys_fn->check_gpu_status) ras_core->sys_fn->check_gpu_status(ras_core, &status); @@ -485,6 +491,9 @@ int ras_core_handle_fatal_error(struct ras_core_context *ras_core) uint32_t ras_core_get_curr_nps_mode(struct ras_core_context *ras_core) { + if (!ras_core) + return 0; + if (ras_core->ras_nbio.ip_func && ras_core->ras_nbio.ip_func->get_memory_partition_mode) return ras_core->ras_nbio.ip_func->get_memory_partition_mode(ras_core); @@ -568,6 +577,8 @@ bool ras_core_ras_interrupt_detected(struct ras_core_context *ras_core) int ras_core_get_gpu_mem(struct ras_core_context *ras_core, enum gpu_mem_type mem_type, struct gpu_mem_block *gpu_mem) { + if (!ras_core || !gpu_mem) + return -EINVAL; if (ras_core->sys_fn && ras_core->sys_fn->get_gpu_mem) return ras_core->sys_fn->get_gpu_mem(ras_core, mem_type, gpu_mem); @@ -578,6 +589,8 @@ int ras_core_get_gpu_mem(struct ras_core_context *ras_core, int ras_core_put_gpu_mem(struct ras_core_context *ras_core, enum gpu_mem_type mem_type, struct gpu_mem_block *gpu_mem) { + if (!ras_core || !gpu_mem) + return -EINVAL; if (ras_core->sys_fn && ras_core->sys_fn->put_gpu_mem) return ras_core->sys_fn->put_gpu_mem(ras_core, mem_type, gpu_mem); -- 2.34.1
