drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper()
Subsystems (3)
PATCH 1/1 drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper()
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit b8d55a90fd55b767c25687747e2b24abd1ef8680 ]
Return invalid error code -EINVAL for invalid block id.
Fixes the below:
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1183 amdgpu_ras_query_error_status_helper() error: we previously assumed 'info' could be null (see line 1176)
[Ajay: applied AMDGPU_RAS_BLOCK_COUNT condition to amdgpu_ras_error_query()
as amdgpu_ras_query_error_status_helper() not present in v5.10, v5.4 amdgpu_ras_query_error_status_helper() was introduced in 8cc0f5669eb6]
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
@@ -765,6 +765,9 @@ int amdgpu_ras_error_query(struct amdgpu_device *adev,if (!obj)return -EINVAL ; +if (!info || info->head.block ==AMDGPU_RAS_BLOCK_COUNT ) +return -EINVAL ; +switch (info->head.block) {case AMDGPU_RAS_BLOCK__UMC :if (adev->umc.funcs->query_ras_error_count)
Signature · 1 line
2.7.4
PATCH 1/1 drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper
From: Srinivasan Shanmugam <[email protected]>
commit b8d55a90fd55b767c25687747e2b24abd1ef8680 upstream
Return invalid error code -EINVAL for invalid block id.
Fixes the below:
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1183 amdgpu_ras_query_error_status_helper() error: we previously assumed 'info' could be null (see line 1176)
[Ajay: applied AMDGPU_RAS_BLOCK_COUNT condition to amdgpu_ras_query_error_status()
as amdgpu_ras_query_error_status_helper() not present in v5.15 amdgpu_ras_query_error_status_helper() was introduced in 8cc0f5669eb6]
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
@@ -820,6 +820,9 @@ int amdgpu_ras_query_error_status(struct amdgpu_device *adev,if (!obj)return -EINVAL ; +if (!info || info->head.block ==AMDGPU_RAS_BLOCK_COUNT ) +return -EINVAL ; +switch (info->head.block) {case AMDGPU_RAS_BLOCK__UMC : if (adev->umc.ras_funcs &&
Signature · 1 line
2.7.4
PATCH 1/1 drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper()
In reply to Ajay KaherFrom: Srinivasan Shanmugam <[email protected]>
commit b8d55a90fd55b767c25687747e2b24abd1ef8680 upstream
Return invalid error code -EINVAL for invalid block id.
Fixes the below:
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1183 amdgpu_ras_query_error_status_helper() error: we previously assumed 'info' could be null (see line 1176)
[Ajay: applied AMDGPU_RAS_BLOCK_COUNT condition to amdgpu_ras_query_error_status()
as amdgpu_ras_query_error_status_helper() not present in v6.6, v6.1 amdgpu_ras_query_error_status_helper() was introduced in 8cc0f5669eb6]
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
@@ -974,6 +974,9 @@ int amdgpu_ras_query_error_status(struct amdgpu_device *adev,if (!obj)return -EINVAL ; +if (!info || info->head.block ==AMDGPU_RAS_BLOCK_COUNT ) +return -EINVAL ; +if (info->head.block ==AMDGPU_RAS_BLOCK__UMC ) {amdgpu_ras_get_ecc_info (adev, &err_data); }else {
Signature · 1 line
2.7.4
Greg KH
maintainerQuoted 18 lines · Ajay Kaher
From: Srinivasan Shanmugam <[email protected]>
[ Upstream commit
b8d55a90fd55b767c25687747e2b24abd1ef8680]Return invalid error code
-EINVALfor invalid block id.Fixes the below:
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:1183amdgpu_ras_query_error_status_helper()error: we previously assumed 'info' could be null (see line 1176)Suggested-by Hawking Zhang <[email protected]>Cc Tao Zhou <[email protected]>Cc Hawking Zhang <[email protected]>Cc Christian König <[email protected]>Cc Alex Deucher <[email protected]>Signed-off-by Srinivasan Shanmugam <[email protected]>Reviewed-by Hawking Zhang <[email protected]>Signed-off-by Alex Deucher <[email protected]>
Quoted 7 lines
[Ajay: applied
AMDGPU_RAS_BLOCK_COUNTcondition toamdgpu_ras_error_query()
asamdgpu_ras_query_error_status_helper()not present in v5.10, v5.4amdgpu_ras_query_error_status_helper()was introduced in8cc0f5669eb6]Signed-off-by Ajay Kaher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +++ 1 file changed, 3 insertions(+)
All now queued up, thanks.
greg k-h