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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 5/13/2024 2:26 PM, Ma Jun wrote:
> Check handle pointer before using it
> 
> Signed-off-by: Ma Jun <Jun.Ma2@xxxxxxx>
> ---
>  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)



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux