drm/amdgpu: Fix potential null pointer derefernce
Subsystems (2)
PATCH 1/1 drm/amdgpu: Fix potential null pointer derefernce
The amdgpu_ras_get_context may return NULL if device not support ras feature, so add check before using.
Signed-off-by Stanley.Yang <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -1
@@ -5391,7 +5391,8 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,* Flush RAM to disk so that after reboot * the user can read log and see why the system rebooted. */ -if (need_emergency_restart &&amdgpu_ras_get_context (adev)->reboot) { +if (need_emergency_restart &&amdgpu_ras_get_context (adev) && +amdgpu_ras_get_context (adev)->reboot) {DRM_WARN ("Emergency reboot." );ksys_sync_helper ();
Signature · 1 line
2.25.1
[AMD Official Use Only - General]
Reviewed-by Tao Zhou <[email protected]>
Quoted 35 lines
-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Stanley.Yang
Sent: Thursday, September 28, 2023 11:46 AM
To: [email protected]
Cc: Yang, Stanley <[email protected]>
Subject: [PATCH Review 1/1] drm/amdgpu: Fix potential null pointer derefernceThe
amdgpu_ras_get_contextmay return NULL if device not support ras feature, so add check before using.Signed-off-by Stanley.Yang <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2
-1@@ -5391,7 +5391,8 @@ int amdgpu_device_gpu_recover(structamdgpu_device *adev, * Flush RAM to disk so that after reboot * the user can read log and see why the system rebooted. */ -if (need_emergency_restart &&amdgpu_ras_get_context (adev)- >reboot) { +if (need_emergency_restart &&amdgpu_ras_get_context (adev) && +amdgpu_ras_get_context (adev)->reboot) {DRM_WARN ("Emergency reboot." );ksys_sync_helper();--
2.25.1