[PATCH 3/5] drm/amdgpu: Fix null pointer dereference to aca_handle

Lazar, Lijo lijo.lazar at amd.com
Mon May 13 10:25:27 UTC 2024



On 5/13/2024 2:26 PM, Ma Jun wrote:
> Check handle pointer before using it
> 
> Signed-off-by: Ma Jun <Jun.Ma2 at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> index 28febf33fb1b..e969a7d77b4d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> @@ -279,7 +279,7 @@ static struct aca_bank_error *get_bank_error(struct aca_error *aerr, struct aca_
>  int aca_error_cache_log_bank_error(struct aca_handle *handle, struct aca_bank_info *info,
>  				   enum aca_error_type type, u64 count)
>  {
> -	struct aca_error_cache *error_cache = &handle->error_cache;
> +	struct aca_error_cache *error_cache;
>  	struct aca_bank_error *bank_error;
>  	struct aca_error *aerr;
>  
> @@ -289,6 +289,10 @@ int aca_error_cache_log_bank_error(struct aca_handle *handle, struct aca_bank_in
>  	if (!count)
>  		return 0;
>  
> +	error_cache = &handle->error_cache;
> +	if (!error_cache)
> +		return -EINVAL;

Similar as in patch 2. error_cache is not a pointer variable.

struct aca_error_cache error_cache;


Thanks,
Lijo

> +
>  	aerr = &error_cache->errors[type];
>  	bank_error = get_bank_error(aerr, info);
>  	if (!bank_error)


More information about the amd-gfx mailing list