* [PATCH] nbio_v7_4: Add pointer check
@ 2022-11-10 12:28 Denis Arefev
2022-11-10 21:42 ` Limonciello, Mario
0 siblings, 1 reply; 4+ messages in thread
From: Denis Arefev @ 2022-11-10 12:28 UTC (permalink / raw)
To: Alex Deucher
Cc: Christian König, avid Airlie, Daniel Vetter, amd-gfx,
dri-devel, linux-kernel
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@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: nbio_v7_4: Add pointer check
2022-11-10 12:28 [PATCH] nbio_v7_4: Add pointer check Denis Arefev
@ 2022-11-10 21:42 ` Limonciello, Mario
0 siblings, 0 replies; 4+ messages in thread
From: Limonciello, Mario @ 2022-11-10 21:42 UTC (permalink / raw)
To: Denis Arefev, Alex Deucher
Cc: avid Airlie, linux-kernel, dri-devel, amd-gfx, Daniel Vetter,
Christian König
On 11/10/2022 06:28, Denis Arefev wrote:
> Return value of a function 'amdgpu_ras_find_obj' is dereferenced at nbio_v7_4.c:325 without checking for null
This line is too long, you should be wrapping lines at 75 characters.
Could you run your patch through checkpatch?
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Signed-off-by: Denis Arefev <arefev@swemel.ru>
Probably should include this tag:
Fixes: 28f87950d935e ("drm/amdgpu: clear ras controller status registers
when interrupt occurs")
> ---
> 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;
>
Whitespace seems inconsistent here.
> 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)) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] nbio_v7_4: Add pointer check
@ 2022-11-11 7:41 Denis Arefev
2022-11-11 9:03 ` Zhang, Hawking
0 siblings, 1 reply; 4+ messages in thread
From: Denis Arefev @ 2022-11-11 7:41 UTC (permalink / raw)
To: Alex Deucher
Cc: Christian König, avid Airlie, Daniel Vetter, amd-gfx,
dri-devel, linux-kernel
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@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] nbio_v7_4: Add pointer check
2022-11-11 7:41 [PATCH] " Denis Arefev
@ 2022-11-11 9:03 ` Zhang, Hawking
0 siblings, 0 replies; 4+ messages in thread
From: Zhang, Hawking @ 2022-11-11 9:03 UTC (permalink / raw)
To: Denis Arefev, Deucher, Alexander
Cc: avid Airlie, linux-kernel, dri-devel, amd-gfx, Daniel Vetter,
Koenig, Christian
[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@lists.freedesktop.org> On Behalf Of Denis Arefev
Sent: Friday, November 11, 2022 15:41
To: Deucher, Alexander <Alexander.Deucher@amd.com>
Cc: avid Airlie <airlied@linux.ie>; linux-kernel@vger.kernel.org; dri-devel@lists.freedesktop.org; amd-gfx@lists.freedesktop.org; Daniel Vetter <daniel@ffwll.ch>; Koenig, Christian <Christian.Koenig@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@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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-11-11 9:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-10 12:28 [PATCH] nbio_v7_4: Add pointer check Denis Arefev
2022-11-10 21:42 ` Limonciello, Mario
2022-11-11 7:41 [PATCH] " Denis Arefev
2022-11-11 9:03 ` Zhang, Hawking
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).