[PATCH] drm/amdgpu: Handle potential NULL pointer dereference
Lazar, Lijo
lijo.lazar at amd.com
Thu Aug 25 12:34:11 UTC 2022
On 8/25/2022 5:16 PM, Russell, Kent wrote:
> [AMD Official Use Only - General]
>
> Friendly ping
>
Wonder how it goes any further when m is NULL. It should do shortcut
evaluation and return NOTIFY_DONE, right? Or is this for better readability?
Thanks,
Lijo
> Kent
>
> -----Original Message-----
> From: Russell, Kent <Kent.Russell at amd.com>
> Sent: Monday, August 15, 2022 11:31 AM
> To: amd-gfx at lists.freedesktop.org
> Cc: Ghannam, Yazen <Yazen.Ghannam at amd.com>; Russell, Kent <Kent.Russell at 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.russell at 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
>
More information about the amd-gfx
mailing list