[PATCH] nbio_v7_4: Add pointer check

Zhang, Hawking Hawking.Zhang at amd.com
Fri Nov 11 09:03:35 UTC 2022


[AMD Official Use Only - General]

Hey,

The patch does the right thing from coding principal perspective, but it is really redundant check in RAS context.

The function is a hardware interrupt handler which is only triggered for specific RAS event. When software receives the interrupt, the pointer of RAS context must be valid one. Otherwise, even the interrupt won't be enabled at all...

Regards,
Hawking

-----Original Message-----
From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Denis Arefev
Sent: Friday, November 11, 2022 15:41
To: Deucher, Alexander <Alexander.Deucher at amd.com>
Cc: avid Airlie <airlied at linux.ie>; linux-kernel at vger.kernel.org; dri-devel at lists.freedesktop.org; amd-gfx at lists.freedesktop.org; Daniel Vetter <daniel at ffwll.ch>; Koenig, Christian <Christian.Koenig at amd.com>
Subject: [PATCH] nbio_v7_4: Add pointer check

Return value of a function 'amdgpu_ras_find_obj' is dereferenced at nbio_v7_4.c:325 without checking for null

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Denis Arefev <arefev at swemel.ru>
---
 drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c b/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c
index eadc9526d33f..0f2ac99de864 100644
--- a/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/nbio_v7_4.c
@@ -304,6 +304,9 @@ static void nbio_v7_4_handle_ras_controller_intr_no_bifring(struct amdgpu_device
 	struct ras_err_data err_data = {0, 0, 0, NULL};
 	struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
 
+	if (!obj)
+	  return;
 
 	bif_doorbell_intr_cntl = RREG32_SOC15(NBIO, 0, mmBIF_DOORBELL_INT_CNTL);
 	if (REG_GET_FIELD(bif_doorbell_intr_cntl,
 		BIF_DOORBELL_INT_CNTL, RAS_CNTLR_INTERRUPT_STATUS)) {
--
2.25.1


More information about the dri-devel mailing list