public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5.10, v5.4] drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper()
@ 2024-05-21 12:22 Ajay Kaher
  2024-05-21 12:22 ` [PATCH v5.15] drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper Ajay Kaher
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ajay Kaher @ 2024-05-21 12:22 UTC (permalink / raw)
  To: stable, gregkh
  Cc: ajay.kaher, alexey.makhalov, vasavi.sirnapalli, Tao Zhou,
	Hawking Zhang, Christian König, Alex Deucher,
	Srinivasan Shanmugam

From: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>

[ 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)

Suggested-by: Hawking Zhang <Hawking.Zhang@amd.com>
Cc: Tao Zhou <tao.zhou1@amd.com>
Cc: Hawking Zhang <Hawking.Zhang@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
[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]
Signed-off-by: Ajay Kaher <ajay.kaher@broadcom.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 a8f1c49..e971d2b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -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)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-23 12:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-21 12:22 [PATCH v5.10, v5.4] drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper() Ajay Kaher
2024-05-21 12:22 ` [PATCH v5.15] drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper Ajay Kaher
2024-05-21 12:22 ` [PATCH v6.6, v6.1] drm/amdgpu: Fix possible NULL dereference in amdgpu_ras_query_error_status_helper() Ajay Kaher
2024-05-23 12:06 ` [PATCH v5.10, v5.4] " Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox