linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] media: staging: intel-ipu3: fix unsigned comparison with < 0
@ 2018-12-22 11:49 Colin King
  2019-02-02 22:12 ` Colin Ian King
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2018-12-22 11:49 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	linux-media, devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The comparison css->pipes[pipe].bindex < 0 is always false because
bindex is an unsigned int.  Fix this by using a signed integer for
the comparison.

Detected by CoverityScan, CID#1476023 ("Unsigned compared against 0")

Fixes: f5f2e4273518 ("media: staging/intel-ipu3: Add css pipeline programming")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/staging/media/ipu3/ipu3-css.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
index 44c55639389a..b9354d2bb692 100644
--- a/drivers/staging/media/ipu3/ipu3-css.c
+++ b/drivers/staging/media/ipu3/ipu3-css.c
@@ -1751,7 +1751,7 @@ int ipu3_css_fmt_try(struct ipu3_css *css,
 					&q[IPU3_CSS_QUEUE_OUT].fmt.mpix;
 	struct v4l2_pix_format_mplane *const vf =
 					&q[IPU3_CSS_QUEUE_VF].fmt.mpix;
-	int i, s;
+	int i, s, ret;
 
 	/* Adjust all formats, get statistics buffer sizes and formats */
 	for (i = 0; i < IPU3_CSS_QUEUES; i++) {
@@ -1826,12 +1826,12 @@ int ipu3_css_fmt_try(struct ipu3_css *css,
 	s = (bds->height - gdc->height) / 2 - FILTER_SIZE;
 	env->height = s < MIN_ENVELOPE ? MIN_ENVELOPE : s;
 
-	css->pipes[pipe].bindex =
-		ipu3_css_find_binary(css, pipe, q, r);
-	if (css->pipes[pipe].bindex < 0) {
+	ret = ipu3_css_find_binary(css, pipe, q, r);
+	if (ret < 0) {
 		dev_err(css->dev, "failed to find suitable binary\n");
 		return -EINVAL;
 	}
+	css->pipes[pipe].bindex = ret;
 
 	dev_dbg(css->dev, "Binary index %d for pipe %d found.",
 		css->pipes[pipe].bindex, pipe);
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] media: staging: intel-ipu3: fix unsigned comparison with < 0
  2018-12-22 11:49 [PATCH][next] media: staging: intel-ipu3: fix unsigned comparison with < 0 Colin King
@ 2019-02-02 22:12 ` Colin Ian King
  2019-02-04  8:56   ` Sakari Ailus
  0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2019-02-02 22:12 UTC (permalink / raw)
  To: Sakari Ailus, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	linux-media, devel
  Cc: kernel-janitors, linux-kernel

ping?

On 22/12/2018 11:49, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The comparison css->pipes[pipe].bindex < 0 is always false because
> bindex is an unsigned int.  Fix this by using a signed integer for
> the comparison.
> 
> Detected by CoverityScan, CID#1476023 ("Unsigned compared against 0")
> 
> Fixes: f5f2e4273518 ("media: staging/intel-ipu3: Add css pipeline programming")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/staging/media/ipu3/ipu3-css.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
> index 44c55639389a..b9354d2bb692 100644
> --- a/drivers/staging/media/ipu3/ipu3-css.c
> +++ b/drivers/staging/media/ipu3/ipu3-css.c
> @@ -1751,7 +1751,7 @@ int ipu3_css_fmt_try(struct ipu3_css *css,
>  					&q[IPU3_CSS_QUEUE_OUT].fmt.mpix;
>  	struct v4l2_pix_format_mplane *const vf =
>  					&q[IPU3_CSS_QUEUE_VF].fmt.mpix;
> -	int i, s;
> +	int i, s, ret;
>  
>  	/* Adjust all formats, get statistics buffer sizes and formats */
>  	for (i = 0; i < IPU3_CSS_QUEUES; i++) {
> @@ -1826,12 +1826,12 @@ int ipu3_css_fmt_try(struct ipu3_css *css,
>  	s = (bds->height - gdc->height) / 2 - FILTER_SIZE;
>  	env->height = s < MIN_ENVELOPE ? MIN_ENVELOPE : s;
>  
> -	css->pipes[pipe].bindex =
> -		ipu3_css_find_binary(css, pipe, q, r);
> -	if (css->pipes[pipe].bindex < 0) {
> +	ret = ipu3_css_find_binary(css, pipe, q, r);
> +	if (ret < 0) {
>  		dev_err(css->dev, "failed to find suitable binary\n");
>  		return -EINVAL;
>  	}
> +	css->pipes[pipe].bindex = ret;
>  
>  	dev_dbg(css->dev, "Binary index %d for pipe %d found.",
>  		css->pipes[pipe].bindex, pipe);
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] media: staging: intel-ipu3: fix unsigned comparison with < 0
  2019-02-02 22:12 ` Colin Ian King
@ 2019-02-04  8:56   ` Sakari Ailus
  0 siblings, 0 replies; 3+ messages in thread
From: Sakari Ailus @ 2019-02-04  8:56 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Mauro Carvalho Chehab, Greg Kroah-Hartman, linux-media, devel,
	kernel-janitors, linux-kernel

On Sat, Feb 02, 2019 at 10:12:41PM +0000, Colin Ian King wrote:
> ping?

I seem to have applied this to a wrong branch, it'll now be part of my next
pull request to Mauro.

Thanks!

> 
> On 22/12/2018 11:49, Colin King wrote:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > The comparison css->pipes[pipe].bindex < 0 is always false because
> > bindex is an unsigned int.  Fix this by using a signed integer for
> > the comparison.
> > 
> > Detected by CoverityScan, CID#1476023 ("Unsigned compared against 0")
> > 
> > Fixes: f5f2e4273518 ("media: staging/intel-ipu3: Add css pipeline programming")
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  drivers/staging/media/ipu3/ipu3-css.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/staging/media/ipu3/ipu3-css.c b/drivers/staging/media/ipu3/ipu3-css.c
> > index 44c55639389a..b9354d2bb692 100644
> > --- a/drivers/staging/media/ipu3/ipu3-css.c
> > +++ b/drivers/staging/media/ipu3/ipu3-css.c
> > @@ -1751,7 +1751,7 @@ int ipu3_css_fmt_try(struct ipu3_css *css,
> >  					&q[IPU3_CSS_QUEUE_OUT].fmt.mpix;
> >  	struct v4l2_pix_format_mplane *const vf =
> >  					&q[IPU3_CSS_QUEUE_VF].fmt.mpix;
> > -	int i, s;
> > +	int i, s, ret;
> >  
> >  	/* Adjust all formats, get statistics buffer sizes and formats */
> >  	for (i = 0; i < IPU3_CSS_QUEUES; i++) {
> > @@ -1826,12 +1826,12 @@ int ipu3_css_fmt_try(struct ipu3_css *css,
> >  	s = (bds->height - gdc->height) / 2 - FILTER_SIZE;
> >  	env->height = s < MIN_ENVELOPE ? MIN_ENVELOPE : s;
> >  
> > -	css->pipes[pipe].bindex =
> > -		ipu3_css_find_binary(css, pipe, q, r);
> > -	if (css->pipes[pipe].bindex < 0) {
> > +	ret = ipu3_css_find_binary(css, pipe, q, r);
> > +	if (ret < 0) {
> >  		dev_err(css->dev, "failed to find suitable binary\n");
> >  		return -EINVAL;
> >  	}
> > +	css->pipes[pipe].bindex = ret;
> >  
> >  	dev_dbg(css->dev, "Binary index %d for pipe %d found.",
> >  		css->pipes[pipe].bindex, pipe);
> > 
> 

-- 
Sakari Ailus
sakari.ailus@linux.intel.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-04  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-22 11:49 [PATCH][next] media: staging: intel-ipu3: fix unsigned comparison with < 0 Colin King
2019-02-02 22:12 ` Colin Ian King
2019-02-04  8:56   ` Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).