[AMD Official Use Only - General]

Friendly ping

 Kent

-----Original Message-----
From: Russell, Kent <kent.russ...@amd.com> 
Sent: Monday, August 15, 2022 11:31 AM
To: amd-gfx@lists.freedesktop.org
Cc: Ghannam, Yazen <yazen.ghan...@amd.com>; Russell, Kent <kent.russ...@amd.com>
Subject: [PATCH] drm/amdgpu: Handle potential NULL pointer dereference

If m is NULL, we will end up referencing a NULL pointer in the subsequent m 
elements like extcpu, bank and status. Pull the NULL check out and do it first 
before referencing m's elements.

Signed-off-by: Kent Russell <kent.russ...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index ab9ba5a9c33d..028495fdfa62 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -2838,12 +2838,15 @@ static int amdgpu_bad_page_notifier(struct 
notifier_block *nb,
        struct eeprom_table_record err_rec;
        uint64_t retired_page;
 
+       if (!m)
+               return NOTIFY_DONE;
+
        /*
         * If the error was generated in UMC_V2, which belongs to GPU UMCs,
         * and error occurred in DramECC (Extended error code = 0) then only
         * process the error, else bail out.
         */
-       if (!m || !((smca_get_bank_type(m->extcpu, m->bank) == SMCA_UMC_V2) &&
+       if (!((smca_get_bank_type(m->extcpu, m->bank) == SMCA_UMC_V2) &&
                    (XEC(m->status, 0x3f) == 0x0)))
                return NOTIFY_DONE;
 
--
2.25.1

Reply via email to