Skip to contentSkip to conversation

drm/amdgpu: Fix the null pointer dereference for amdgpu_ras_reset_error_status

PATCH New Bob Zhou 1 participant 1 message Jun 20, 2024

Subsystems (2)
lore
Share & tools
lore

Bob Zhou

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix the null pointer dereference for amdgpu_ras_reset_error_status

Check return value and conduct null pointer handling to avoid null pointer dereference.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
index 68e9935028db..0ea836b376a6 100644
@@ -1442,6 +1442,9 @@ int amdgpu_ras_reset_error_status(struct amdgpu_device *adev,
 	if (amdgpu_ras_reset_error_count(adev, block) == -EOPNOTSUPP)
 		return 0;
 
+	if (!block_obj || !block_obj->hw_ops)
+		return -EINVAL;
+
 	if ((block == AMDGPU_RAS_BLOCK__GFX) ||
 	    (block == AMDGPU_RAS_BLOCK__MMHUB)) {
 		if (block_obj->hw_ops->reset_ras_error_status)
Signature · 1 line
2.34.1