Re: [PATCH] drm/msm/dpu: Fix pointer dereferenced before checking

2022-05-30 Thread baihaowen
在 2022/5/30 下午3:33, Haowen Bai 写道:
> The ctx->hw is dereferencing before null checking, so move
> it after checking.
>
> Signed-off-by: Haowen Bai 
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c 
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c
> index be292937..e59680cdd0ce 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c
> @@ -155,11 +155,13 @@ static void dpu_hw_wb_roi(struct dpu_hw_wb *ctx, struct 
> dpu_hw_wb_cfg *wb)
>  static void dpu_hw_wb_setup_qos_lut(struct dpu_hw_wb *ctx,
>   struct dpu_hw_wb_qos_cfg *cfg)
>  {
> - struct dpu_hw_blk_reg_map *c = &ctx->hw;
> + struct dpu_hw_blk_reg_map *c;
>   u32 qos_ctrl = 0;
>  
>   if (!ctx || !cfg)
>   return;
> + 
> + c = &ctx->hw;
>  
>   DPU_REG_WRITE(c, WB_DANGER_LUT, cfg->danger_lut);
>   DPU_REG_WRITE(c, WB_SAFE_LUT, cfg->safe_lut);
Sorry, plz ignore this patch.

ctx->hw is dereferenced, &ctx->hw is just a pointer math for pointer address 
offset, so it would not cause a bug(dereferencing null pointer).

 

-- 
Haowen Bai



Re: [PATCH] drm/msm/dpu: Fix pointer dereferenced before checking

2022-05-30 Thread baihaowen
在 2022/5/31 上午8:36, Abhinav Kumar 写道:
>
>
> On 5/30/2022 12:33 AM, Haowen Bai wrote:
>> The ctx->hw is dereferencing before null checking, so move
>> it after checking.
>>
>> Signed-off-by: Haowen Bai 
>
> Agree with Dmitry's comment. Adjust the patch subject to a different one 
> otherwise PW thinks they are same patches.
>
> Reviewed-by: Abhinav Kumar 
>
>> ---
>>   drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c 
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c
>> index be292937..e59680cdd0ce 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_hw_wb.c
>> @@ -155,11 +155,13 @@ static void dpu_hw_wb_roi(struct dpu_hw_wb *ctx, 
>> struct dpu_hw_wb_cfg *wb)
>>   static void dpu_hw_wb_setup_qos_lut(struct dpu_hw_wb *ctx,
>>   struct dpu_hw_wb_qos_cfg *cfg)
>>   {
>> -    struct dpu_hw_blk_reg_map *c = &ctx->hw;
>> +    struct dpu_hw_blk_reg_map *c;
>>   u32 qos_ctrl = 0;
>>     if (!ctx || !cfg)
>>   return;
>> +   
>> +    c = &ctx->hw;
>>     DPU_REG_WRITE(c, WB_DANGER_LUT, cfg->danger_lut);
>>   DPU_REG_WRITE(c, WB_SAFE_LUT, cfg->safe_lut);
Sorry, plz ignore this patch.

ctx->hw is dereferenced, &ctx->hw is just a pointer math for pointer address 
offset, so it would not cause a bug(dereferencing null pointer).

 

-- 
Haowen Bai



Re: [PATCH] drm/nouveau/therm: Fix pointer dereferenced before checking

2022-05-30 Thread baihaowen


在 2022/5/30 上午11:10, Haowen Bai 写道:
> The fan->base is dereferencing before null checking, so move
> it after checking.
>
> Signed-off-by: Haowen Bai 
> ---
>  drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c 
> b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c
> index 340f37a299dc..b13ba9b2f6be 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/therm/fanpwm.c
> @@ -98,10 +98,10 @@ nvkm_fanpwm_create(struct nvkm_therm *therm, struct 
> dcb_gpio_func *func)
>   return -ENODEV;
>  
>   fan = kzalloc(sizeof(*fan), GFP_KERNEL);
> - therm->fan = &fan->base;
>   if (!fan)
>   return -ENOMEM;
>  
> + therm->fan = &fan->base;
>   fan->base.type = "PWM";
>   fan->base.get = nvkm_fanpwm_get;
>   fan->base.set = nvkm_fanpwm_set;
Sorry, plz ignore this patch.

fan->base is dereferenced, &fan->base is just a pointer math for pointer 
address offset, so it would not cause a bug(dereferencing null pointer).

 

-- 
Haowen Bai



Re: [PATCH] drm/amdgpu/vcn: remove Unneeded semicolon

2022-04-01 Thread baihaowen
在 4/1/22 1:54 PM, Paul Menzel 写道:
> Dear Haowen,
>
>
> Thank you for your patch.
>
> Am 31.03.22 um 07:56 schrieb Haowen Bai:
>
> In the commit message summary, please use:
>
> Remove unneeded semicolon
>
>> report by coccicheck:
>> drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c:1951:2-3: Unneeded semicolon
>>
>> fixed c543dcb ("drm/amdgpu/vcn: Add VCN ras error query support")
>
> Please use
>
> Fixes: …
>
> and a commit hash length of 12 characters. (`scripts/checkpatch.pl …` should 
> tell you about this.)
>
>
> Kind regards,
>
> Paul
>
>
>> Signed-off-by: Haowen Bai 
>> ---
>>   drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c 
>> b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
>> index 3e1de8c..17d44be 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
>> @@ -1948,7 +1948,7 @@ static uint32_t 
>> vcn_v2_6_query_poison_by_instance(struct amdgpu_device *adev,
>>   break;
>>   default:
>>   break;
>> -    };
>> +    }
>>     if (poison_stat)
>>   dev_info(adev->dev, "Poison detected in VCN%d, sub_block%d\n",
hi, Paul Menzel
Thank you for your detail point which I have first known.

-- 
Haowen Bai