2022-06-21 11:16:30

by sunliming

[permalink] [raw]
Subject: [PATCH] drm/msm/dpu: Fix variable dereferenced before check

Fixes the following smatch warning:

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:261
dpu_encoder_phys_wb_atomic_check() warn: variable dereferenced before check 'conn_state'

Reported-by: kernel test robot <[email protected]>
Signed-off-by: sunliming <[email protected]>
---
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
index 59da348ff339..0ec809ab06e7 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
@@ -252,11 +252,6 @@ static int dpu_encoder_phys_wb_atomic_check(
DPU_DEBUG("[atomic_check:%d, \"%s\",%d,%d]\n",
phys_enc->wb_idx, mode->name, mode->hdisplay, mode->vdisplay);

- if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
- return 0;
-
- fb = conn_state->writeback_job->fb;
-
if (!conn_state || !conn_state->connector) {
DPU_ERROR("invalid connector state\n");
return -EINVAL;
@@ -267,6 +262,11 @@ static int dpu_encoder_phys_wb_atomic_check(
return -EINVAL;
}

+ if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
+ return 0;
+
+ fb = conn_state->writeback_job->fb;
+
DPU_DEBUG("[fb_id:%u][fb:%u,%u]\n", fb->base.id,
fb->width, fb->height);

--
2.25.1


2022-06-21 17:54:49

by Abhinav Kumar

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/dpu: Fix variable dereferenced before check



On 6/21/2022 4:06 AM, sunliming wrote:
> Fixes the following smatch warning:
>
> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:261
> dpu_encoder_phys_wb_atomic_check() warn: variable dereferenced before check 'conn_state'
>
> Reported-by: kernel test robot <[email protected]>
> Signed-off-by: sunliming <[email protected]>
Reported-by: Dan Carpenter <[email protected]>
Reviewed-by: Abhinav Kumar <[email protected]>

> ---
> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
> index 59da348ff339..0ec809ab06e7 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
> @@ -252,11 +252,6 @@ static int dpu_encoder_phys_wb_atomic_check(
> DPU_DEBUG("[atomic_check:%d, \"%s\",%d,%d]\n",
> phys_enc->wb_idx, mode->name, mode->hdisplay, mode->vdisplay);
>
> - if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
> - return 0;
> -
> - fb = conn_state->writeback_job->fb;
> -
> if (!conn_state || !conn_state->connector) {
> DPU_ERROR("invalid connector state\n");
> return -EINVAL;
> @@ -267,6 +262,11 @@ static int dpu_encoder_phys_wb_atomic_check(
> return -EINVAL;
> }
>
> + if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
> + return 0;
> +
> + fb = conn_state->writeback_job->fb;
> +
> DPU_DEBUG("[fb_id:%u][fb:%u,%u]\n", fb->base.id,
> fb->width, fb->height);
>

2022-06-21 17:54:59

by Abhinav Kumar

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/dpu: Fix variable dereferenced before check

Copying freedreno

On 6/21/2022 10:42 AM, Abhinav Kumar wrote:
>
>
> On 6/21/2022 4:06 AM, sunliming wrote:
>> Fixes the following smatch warning:
>>
>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:261
>> dpu_encoder_phys_wb_atomic_check() warn: variable dereferenced before
>> check 'conn_state'
>>
>> Reported-by: kernel test robot <[email protected]>
>> Signed-off-by: sunliming <[email protected]>
> Reported-by: Dan Carpenter <[email protected]>
> Reviewed-by: Abhinav Kumar <[email protected]>
>
>> ---
>>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>> index 59da348ff339..0ec809ab06e7 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>> @@ -252,11 +252,6 @@ static int dpu_encoder_phys_wb_atomic_check(
>>       DPU_DEBUG("[atomic_check:%d, \"%s\",%d,%d]\n",
>>               phys_enc->wb_idx, mode->name, mode->hdisplay,
>> mode->vdisplay);
>> -    if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
>> -        return 0;
>> -
>> -    fb = conn_state->writeback_job->fb;
>> -
>>       if (!conn_state || !conn_state->connector) {
>>           DPU_ERROR("invalid connector state\n");
>>           return -EINVAL;
>> @@ -267,6 +262,11 @@ static int dpu_encoder_phys_wb_atomic_check(
>>           return -EINVAL;
>>       }
>> +    if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
>> +        return 0;
>> +
>> +    fb = conn_state->writeback_job->fb;
>> +
>>       DPU_DEBUG("[fb_id:%u][fb:%u,%u]\n", fb->base.id,
>>               fb->width, fb->height);

2022-06-21 18:08:27

by Dmitry Baryshkov

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/dpu: Fix variable dereferenced before check

On Tue, 21 Jun 2022 at 20:44, Abhinav Kumar <[email protected]> wrote:
>
> Copying freedreno

The patch needs to be sent to freedreno@. Otherwise it doesn't exist
in patchwork.

>
> On 6/21/2022 10:42 AM, Abhinav Kumar wrote:
> >
> >
> > On 6/21/2022 4:06 AM, sunliming wrote:
> >> Fixes the following smatch warning:
> >>
> >> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:261
> >> dpu_encoder_phys_wb_atomic_check() warn: variable dereferenced before
> >> check 'conn_state'
> >>
> >> Reported-by: kernel test robot <[email protected]>
> >> Signed-off-by: sunliming <[email protected]>
> > Reported-by: Dan Carpenter <[email protected]>
> > Reviewed-by: Abhinav Kumar <[email protected]>
> >
> >> ---
> >> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 10 +++++-----
> >> 1 file changed, 5 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
> >> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
> >> index 59da348ff339..0ec809ab06e7 100644
> >> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
> >> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
> >> @@ -252,11 +252,6 @@ static int dpu_encoder_phys_wb_atomic_check(
> >> DPU_DEBUG("[atomic_check:%d, \"%s\",%d,%d]\n",
> >> phys_enc->wb_idx, mode->name, mode->hdisplay,
> >> mode->vdisplay);
> >> - if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
> >> - return 0;
> >> -
> >> - fb = conn_state->writeback_job->fb;
> >> -
> >> if (!conn_state || !conn_state->connector) {
> >> DPU_ERROR("invalid connector state\n");
> >> return -EINVAL;
> >> @@ -267,6 +262,11 @@ static int dpu_encoder_phys_wb_atomic_check(
> >> return -EINVAL;
> >> }
> >> + if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
> >> + return 0;
> >> +
> >> + fb = conn_state->writeback_job->fb;
> >> +
> >> DPU_DEBUG("[fb_id:%u][fb:%u,%u]\n", fb->base.id,
> >> fb->width, fb->height);



--
With best wishes
Dmitry

2022-06-22 17:39:36

by Abhinav Kumar

[permalink] [raw]
Subject: Re: [PATCH] drm/msm/dpu: Fix variable dereferenced before check



On 6/21/2022 10:49 AM, Dmitry Baryshkov wrote:
> On Tue, 21 Jun 2022 at 20:44, Abhinav Kumar <[email protected]> wrote:
>>
>> Copying freedreno
>
> The patch needs to be sent to freedreno@. Otherwise it doesn't exist
> in patchwork.

Ack

Hi Sunliming

Can you please re-send this and copy freedreno email list along with the
Reviewed-by and Reported-by tags which I have given below?

Thanks

Abhinav

>
>>
>> On 6/21/2022 10:42 AM, Abhinav Kumar wrote:
>>>
>>>
>>> On 6/21/2022 4:06 AM, sunliming wrote:
>>>> Fixes the following smatch warning:
>>>>
>>>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c:261
>>>> dpu_encoder_phys_wb_atomic_check() warn: variable dereferenced before
>>>> check 'conn_state'
>>>>
>>>> Reported-by: kernel test robot <[email protected]>
>>>> Signed-off-by: sunliming <[email protected]>
>>> Reported-by: Dan Carpenter <[email protected]>
>>> Reviewed-by: Abhinav Kumar <[email protected]>
>>>
>>>> ---
>>>> drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c | 10 +++++-----
>>>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>>>> index 59da348ff339..0ec809ab06e7 100644
>>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder_phys_wb.c
>>>> @@ -252,11 +252,6 @@ static int dpu_encoder_phys_wb_atomic_check(
>>>> DPU_DEBUG("[atomic_check:%d, \"%s\",%d,%d]\n",
>>>> phys_enc->wb_idx, mode->name, mode->hdisplay,
>>>> mode->vdisplay);
>>>> - if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
>>>> - return 0;
>>>> -
>>>> - fb = conn_state->writeback_job->fb;
>>>> -
>>>> if (!conn_state || !conn_state->connector) {
>>>> DPU_ERROR("invalid connector state\n");
>>>> return -EINVAL;
>>>> @@ -267,6 +262,11 @@ static int dpu_encoder_phys_wb_atomic_check(
>>>> return -EINVAL;
>>>> }
>>>> + if (!conn_state->writeback_job || !conn_state->writeback_job->fb)
>>>> + return 0;
>>>> +
>>>> + fb = conn_state->writeback_job->fb;
>>>> +
>>>> DPU_DEBUG("[fb_id:%u][fb:%u,%u]\n", fb->base.id,
>>>> fb->width, fb->height);
>
>
>