Skip to contentSkip to conversation

media: staging: intel-ipu3: fix unsigned comparison with < 0

PATCH In review Colin King 2 participants 3 messages Dec 22, 2018 – Feb 4, 2019

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 media: staging: intel-ipu3: fix unsigned comparison with < 0

From: Colin Ian King <[email protected]>

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")
---
 drivers/staging/media/ipu3/ipu3-css.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/media/ipu3/ipu3-css.c +4 -3
index 44c55639389a..b9354d2bb692 100644
@@ -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);
Signature · 1 line
2.19.1
#1 lore raw

ping?

Quoted 42 lines · Colin King

From: Colin Ian King <[email protected]>

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")
---
 drivers/staging/media/ipu3/ipu3-css.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/media/ipu3/ipu3-css.c +4 -3
index 44c55639389a..b9354d2bb692 100644
@@ -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);
maintainer
#2 lore raw
Quoted 1 line · Colin Ian King

ping?

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

Thanks!

Quoted 45 lines · Colin King
Quoted 42 lines

From: Colin Ian King <[email protected]>

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")
---
 drivers/staging/media/ipu3/ipu3-css.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/media/ipu3/ipu3-css.c +4 -3
index 44c55639389a..b9354d2bb692 100644
@@ -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);
Signature · 2 lines
Sakari Ailus
[email protected]