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

Bob Zhou bob.zhou at amd.com
Thu Jun 20 07:04:32 UTC 2024


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

Signed-off-by: Bob Zhou <bob.zhou at amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 68e9935028db..0ea836b376a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -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)
-- 
2.34.1



More information about the amd-gfx mailing list