LinuxTV Patchwork [4/6] vsp1: fix smatch warning

login
register
mail settings
Submitter Hans Verkuil
Date Feb. 7, 2019, 9:13 a.m.
Message ID <20190207091338.55705-5-hverkuil-cisco@xs4all.nl>
Download mbox | patch
Permalink /patch/54356/
State Accepted
Delegated to: Hans Verkuil
Headers show

Comments

Hans Verkuil - Feb. 7, 2019, 9:13 a.m.
drivers/media/platform/vsp1/vsp1_drm.c: drivers/media/platform/vsp1/vsp1_drm.c:336 vsp1_du_pipeline_setup_brx() error: we previously assumed 'pipe->brx' could be null (see line 244)

smatch missed that if pipe->brx was NULL, then later on it will be
set with a non-NULL value. But it is easier to just use the brx pointer
so smatch doesn't get confused.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
---
 drivers/media/platform/vsp1/vsp1_drm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Kieran Bingham - Feb. 12, 2019, 1:48 p.m.
Hi Hans,

On 07/02/2019 09:13, Hans Verkuil wrote:
> drivers/media/platform/vsp1/vsp1_drm.c: drivers/media/platform/vsp1/vsp1_drm.c:336 vsp1_du_pipeline_setup_brx() error: we previously assumed 'pipe->brx' could be null (see line 244)
> 
> smatch missed that if pipe->brx was NULL, then later on it will be
> set with a non-NULL value. But it is easier to just use the brx pointer
> so smatch doesn't get confused.
> 

Aha, my initial reaction to this was "Oh - but we've already looked at
this and it was a false positive ..." And then I looked at your patch ...

So my initial reaction was completely wrong - and you have indeed got a
good patch :)

As this function is to 'setup the brx' I think it's very reasonable to
use the chosen BRX pointer to do the configuration. (once all the
dancing has gone on to swap as necessary)

Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>

And for sanity, I've tested this with our VSP Tests on both:

  Salvator-XS-H3 ES2.0 : 164 tests: 148 passed, 0 failed, 3 skipped
and
  Salvator-XS-M3N      : 164 tests: 148 passed, 0 failed, 3 skipped


Tested-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Tested-on: Salvator-XS-ES2.0, Salvator-XS-M3N

> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/media/platform/vsp1/vsp1_drm.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
> index 8d86f618ec77..84895385d2e5 100644
> --- a/drivers/media/platform/vsp1/vsp1_drm.c
> +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> @@ -333,19 +333,19 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
>  	 * on the BRx sink pad 0 and propagated inside the entity, not on the
>  	 * source pad.
>  	 */
> -	format.pad = pipe->brx->source_pad;
> +	format.pad = brx->source_pad;
>  	format.format.width = drm_pipe->width;
>  	format.format.height = drm_pipe->height;
>  	format.format.field = V4L2_FIELD_NONE;
>  
> -	ret = v4l2_subdev_call(&pipe->brx->subdev, pad, set_fmt, NULL,
> +	ret = v4l2_subdev_call(&brx->subdev, pad, set_fmt, NULL,
>  			       &format);
>  	if (ret < 0)
>  		return ret;
>  
>  	dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on %s pad %u\n",
>  		__func__, format.format.width, format.format.height,
> -		format.format.code, BRX_NAME(pipe->brx), pipe->brx->source_pad);
> +		format.format.code, BRX_NAME(brx), brx->source_pad);
>  
>  	if (format.format.width != drm_pipe->width ||
>  	    format.format.height != drm_pipe->height) {
>
Laurent Pinchart - Feb. 12, 2019, 4:31 p.m.
On Tue, Feb 12, 2019 at 01:48:00PM +0000, Kieran Bingham wrote:
> On 07/02/2019 09:13, Hans Verkuil wrote:
> > drivers/media/platform/vsp1/vsp1_drm.c: drivers/media/platform/vsp1/vsp1_drm.c:336 vsp1_du_pipeline_setup_brx() error: we previously assumed 'pipe->brx' could be null (see line 244)
> > 
> > smatch missed that if pipe->brx was NULL, then later on it will be
> > set with a non-NULL value. But it is easier to just use the brx pointer
> > so smatch doesn't get confused.
> > 
> 
> Aha, my initial reaction to this was "Oh - but we've already looked at
> this and it was a false positive ..." And then I looked at your patch ...
> 
> So my initial reaction was completely wrong - and you have indeed got a
> good patch :)
> 
> As this function is to 'setup the brx' I think it's very reasonable to
> use the chosen BRX pointer to do the configuration. (once all the
> dancing has gone on to swap as necessary)
> 
> Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> 
> And for sanity, I've tested this with our VSP Tests on both:
> 
>   Salvator-XS-H3 ES2.0 : 164 tests: 148 passed, 0 failed, 3 skipped
> and
>   Salvator-XS-M3N      : 164 tests: 148 passed, 0 failed, 3 skipped
> 
> 
> Tested-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
> Tested-on: Salvator-XS-ES2.0, Salvator-XS-M3N

Taken in my tree with all these tags and my

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> > Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> > ---
> >  drivers/media/platform/vsp1/vsp1_drm.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
> > index 8d86f618ec77..84895385d2e5 100644
> > --- a/drivers/media/platform/vsp1/vsp1_drm.c
> > +++ b/drivers/media/platform/vsp1/vsp1_drm.c
> > @@ -333,19 +333,19 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
> >  	 * on the BRx sink pad 0 and propagated inside the entity, not on the
> >  	 * source pad.
> >  	 */
> > -	format.pad = pipe->brx->source_pad;
> > +	format.pad = brx->source_pad;
> >  	format.format.width = drm_pipe->width;
> >  	format.format.height = drm_pipe->height;
> >  	format.format.field = V4L2_FIELD_NONE;
> >  
> > -	ret = v4l2_subdev_call(&pipe->brx->subdev, pad, set_fmt, NULL,
> > +	ret = v4l2_subdev_call(&brx->subdev, pad, set_fmt, NULL,
> >  			       &format);
> >  	if (ret < 0)
> >  		return ret;
> >  
> >  	dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on %s pad %u\n",
> >  		__func__, format.format.width, format.format.height,
> > -		format.format.code, BRX_NAME(pipe->brx), pipe->brx->source_pad);
> > +		format.format.code, BRX_NAME(brx), brx->source_pad);
> >  
> >  	if (format.format.width != drm_pipe->width ||
> >  	    format.format.height != drm_pipe->height) {

Patch

diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c
index 8d86f618ec77..84895385d2e5 100644
--- a/drivers/media/platform/vsp1/vsp1_drm.c
+++ b/drivers/media/platform/vsp1/vsp1_drm.c
@@ -333,19 +333,19 @@  static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1,
 	 * on the BRx sink pad 0 and propagated inside the entity, not on the
 	 * source pad.
 	 */
-	format.pad = pipe->brx->source_pad;
+	format.pad = brx->source_pad;
 	format.format.width = drm_pipe->width;
 	format.format.height = drm_pipe->height;
 	format.format.field = V4L2_FIELD_NONE;
 
-	ret = v4l2_subdev_call(&pipe->brx->subdev, pad, set_fmt, NULL,
+	ret = v4l2_subdev_call(&brx->subdev, pad, set_fmt, NULL,
 			       &format);
 	if (ret < 0)
 		return ret;
 
 	dev_dbg(vsp1->dev, "%s: set format %ux%u (%x) on %s pad %u\n",
 		__func__, format.format.width, format.format.height,
-		format.format.code, BRX_NAME(pipe->brx), pipe->brx->source_pad);
+		format.format.code, BRX_NAME(brx), brx->source_pad);
 
 	if (format.format.width != drm_pipe->width ||
 	    format.format.height != drm_pipe->height) {

Privacy Policy