Skip to contentSkip to conversation

drm/amdgpu: Fix potential null pointer derefernce

PATCH In review Stanley.Yang 2 participants 2 messages Sep 28, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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.

---
 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
index cca3faf4dc23..60f8a18592b7 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw

[AMD Official Use Only - General]

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 derefernce

The amdgpu_ras_get_context may return NULL if device not support ras feature, so add check before using.

---
 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
index cca3faf4dc23..60f8a18592b7 100644
@@ -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();

--
2.25.1