All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: v4l2-ioctl: prevent underflow in v4l_enumoutput()
@ 2018-05-17  9:05 ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2018-05-17  9:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Manjunath Hadli
  Cc: Hans Verkuil, Sakari Ailus, Sylwester Nawrocki, Tim Harvey,
	Guennadi Liakhovetski, Smitha T Murthy, Sami Tolvanen,
	linux-media, kernel-janitors

My Smatch allmodconfig build only detects one function implementing
vpbe_device_ops->enum_outputs and that's vpbe_enum_outputs().  The
problem really happens in that function when we do:

	int temp_index = output->index;

	if (temp_index >= cfg->num_outputs)
		return -EINVAL;

Unfortunately, both temp_index and cfg->num_outputs are type int so we
have a potential read before the start of the array if "temp_index" is
negative.

I could have fixed the bug in that function but it's more secure and
future proof to block that bug earlier in a central place.  There is no
one who need p->index to be more than INT_MAX.

Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index a40dbec271f1..115757ab8bc0 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1099,6 +1099,9 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
 	if (is_valid_ioctl(vfd, VIDIOC_S_STD))
 		p->capabilities |= V4L2_OUT_CAP_STD;
 
+	if (p->index > INT_MAX)
+		return -EINVAL;
+
 	return ops->vidioc_enum_output(file, fh, p);
 }
 

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

* [PATCH] media: v4l2-ioctl: prevent underflow in v4l_enumoutput()
@ 2018-05-17  9:05 ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2018-05-17  9:05 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Manjunath Hadli
  Cc: Hans Verkuil, Sakari Ailus, Sylwester Nawrocki, Tim Harvey,
	Guennadi Liakhovetski, Smitha T Murthy, Sami Tolvanen,
	linux-media, kernel-janitors

My Smatch allmodconfig build only detects one function implementing
vpbe_device_ops->enum_outputs and that's vpbe_enum_outputs().  The
problem really happens in that function when we do:

	int temp_index = output->index;

	if (temp_index >= cfg->num_outputs)
		return -EINVAL;

Unfortunately, both temp_index and cfg->num_outputs are type int so we
have a potential read before the start of the array if "temp_index" is
negative.

I could have fixed the bug in that function but it's more secure and
future proof to block that bug earlier in a central place.  There is no
one who need p->index to be more than INT_MAX.

Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index a40dbec271f1..115757ab8bc0 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1099,6 +1099,9 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
 	if (is_valid_ioctl(vfd, VIDIOC_S_STD))
 		p->capabilities |= V4L2_OUT_CAP_STD;
 
+	if (p->index > INT_MAX)
+		return -EINVAL;
+
 	return ops->vidioc_enum_output(file, fh, p);
 }
 

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

* Re: [PATCH] media: v4l2-ioctl: prevent underflow in v4l_enumoutput()
  2018-05-17  9:05 ` Dan Carpenter
@ 2018-05-25  9:06   ` Hans Verkuil
  -1 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2018-05-25  9:06 UTC (permalink / raw)
  To: Dan Carpenter, Mauro Carvalho Chehab, Manjunath Hadli
  Cc: Hans Verkuil, Sakari Ailus, Sylwester Nawrocki, Tim Harvey,
	Guennadi Liakhovetski, Smitha T Murthy, Sami Tolvanen,
	linux-media, kernel-janitors

On 17/05/18 11:05, Dan Carpenter wrote:
> My Smatch allmodconfig build only detects one function implementing
> vpbe_device_ops->enum_outputs and that's vpbe_enum_outputs().  The
> problem really happens in that function when we do:
> 
> 	int temp_index = output->index;
> 
> 	if (temp_index >= cfg->num_outputs)
> 		return -EINVAL;
> 
> Unfortunately, both temp_index and cfg->num_outputs are type int so we
> have a potential read before the start of the array if "temp_index" is
> negative.

Why not fix it in this driver? Make num_outputs unsigned, as it should be.

I really don't like having a random index check in the core. If we ever
want to do such things in the core, then it needs to be implemented
consistently for all ioctls that do something similar.

Regards,

	Hans

> 
> I could have fixed the bug in that function but it's more secure and
> future proof to block that bug earlier in a central place.  There is no
> one who need p->index to be more than INT_MAX.
> 
> Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index a40dbec271f1..115757ab8bc0 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1099,6 +1099,9 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
>  	if (is_valid_ioctl(vfd, VIDIOC_S_STD))
>  		p->capabilities |= V4L2_OUT_CAP_STD;
>  
> +	if (p->index > INT_MAX)
> +		return -EINVAL;
> +
>  	return ops->vidioc_enum_output(file, fh, p);
>  }
>  
> 

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

* Re: [PATCH] media: v4l2-ioctl: prevent underflow in v4l_enumoutput()
@ 2018-05-25  9:06   ` Hans Verkuil
  0 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2018-05-25  9:06 UTC (permalink / raw)
  To: Dan Carpenter, Mauro Carvalho Chehab, Manjunath Hadli
  Cc: Hans Verkuil, Sakari Ailus, Sylwester Nawrocki, Tim Harvey,
	Guennadi Liakhovetski, Smitha T Murthy, Sami Tolvanen,
	linux-media, kernel-janitors

On 17/05/18 11:05, Dan Carpenter wrote:
> My Smatch allmodconfig build only detects one function implementing
> vpbe_device_ops->enum_outputs and that's vpbe_enum_outputs().  The
> problem really happens in that function when we do:
> 
> 	int temp_index = output->index;
> 
> 	if (temp_index >= cfg->num_outputs)
> 		return -EINVAL;
> 
> Unfortunately, both temp_index and cfg->num_outputs are type int so we
> have a potential read before the start of the array if "temp_index" is
> negative.

Why not fix it in this driver? Make num_outputs unsigned, as it should be.

I really don't like having a random index check in the core. If we ever
want to do such things in the core, then it needs to be implemented
consistently for all ioctls that do something similar.

Regards,

	Hans

> 
> I could have fixed the bug in that function but it's more secure and
> future proof to block that bug earlier in a central place.  There is no
> one who need p->index to be more than INT_MAX.
> 
> Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
> index a40dbec271f1..115757ab8bc0 100644
> --- a/drivers/media/v4l2-core/v4l2-ioctl.c
> +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
> @@ -1099,6 +1099,9 @@ static int v4l_enumoutput(const struct v4l2_ioctl_ops *ops,
>  	if (is_valid_ioctl(vfd, VIDIOC_S_STD))
>  		p->capabilities |= V4L2_OUT_CAP_STD;
>  
> +	if (p->index > INT_MAX)
> +		return -EINVAL;
> +
>  	return ops->vidioc_enum_output(file, fh, p);
>  }
>  
> 


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

* [PATCH v2] media: davinci vpbe: array underflow in vpbe_enum_outputs()
  2018-05-25  9:06   ` Hans Verkuil
@ 2018-05-25 13:12     ` Dan Carpenter
  -1 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2018-05-25 13:12 UTC (permalink / raw)
  To: Lad, Prabhakar, Manjunath Hadli, Hans Verkuil
  Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors

In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
the problem is that temp_index can be negative.  I've made
cgf->num_outputs unsigned to fix this issue.

Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: fix it a different way

diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
index 79a566d7defd..180a05e91497 100644
--- a/include/media/davinci/vpbe.h
+++ b/include/media/davinci/vpbe.h
@@ -92,7 +92,7 @@ struct vpbe_config {
 	struct encoder_config_info *ext_encoders;
 	/* amplifier information goes here */
 	struct amp_config_info *amp;
-	int num_outputs;
+	unsigned int num_outputs;
 	/* Order is venc outputs followed by LCD and then external encoders */
 	struct vpbe_output *outputs;
 };

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

* [PATCH v2] media: davinci vpbe: array underflow in vpbe_enum_outputs()
@ 2018-05-25 13:12     ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2018-05-25 13:12 UTC (permalink / raw)
  To: Lad, Prabhakar, Manjunath Hadli, Hans Verkuil
  Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors

In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
the problem is that temp_index can be negative.  I've made
cgf->num_outputs unsigned to fix this issue.

Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: fix it a different way

diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
index 79a566d7defd..180a05e91497 100644
--- a/include/media/davinci/vpbe.h
+++ b/include/media/davinci/vpbe.h
@@ -92,7 +92,7 @@ struct vpbe_config {
 	struct encoder_config_info *ext_encoders;
 	/* amplifier information goes here */
 	struct amp_config_info *amp;
-	int num_outputs;
+	unsigned int num_outputs;
 	/* Order is venc outputs followed by LCD and then external encoders */
 	struct vpbe_output *outputs;
 };

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

* Re: [PATCH v2] media: davinci vpbe: array underflow in vpbe_enum_outputs()
  2018-05-25 13:12     ` Dan Carpenter
@ 2018-05-25 13:16       ` Hans Verkuil
  -1 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2018-05-25 13:16 UTC (permalink / raw)
  To: Dan Carpenter, Lad, Prabhakar, Manjunath Hadli
  Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors

On 25/05/18 15:12, Dan Carpenter wrote:
> In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
> the problem is that temp_index can be negative.  I've made
> cgf->num_outputs unsigned to fix this issue.

Shouldn't temp_index also be made unsigned? It certainly would make a lot of
sense to do that.

Regards,

	Hans

> 
> Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: fix it a different way
> 
> diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
> index 79a566d7defd..180a05e91497 100644
> --- a/include/media/davinci/vpbe.h
> +++ b/include/media/davinci/vpbe.h
> @@ -92,7 +92,7 @@ struct vpbe_config {
>  	struct encoder_config_info *ext_encoders;
>  	/* amplifier information goes here */
>  	struct amp_config_info *amp;
> -	int num_outputs;
> +	unsigned int num_outputs;
>  	/* Order is venc outputs followed by LCD and then external encoders */
>  	struct vpbe_output *outputs;
>  };
> 

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

* Re: [PATCH v2] media: davinci vpbe: array underflow in vpbe_enum_outputs()
@ 2018-05-25 13:16       ` Hans Verkuil
  0 siblings, 0 replies; 13+ messages in thread
From: Hans Verkuil @ 2018-05-25 13:16 UTC (permalink / raw)
  To: Dan Carpenter, Lad, Prabhakar, Manjunath Hadli
  Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors

On 25/05/18 15:12, Dan Carpenter wrote:
> In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
> the problem is that temp_index can be negative.  I've made
> cgf->num_outputs unsigned to fix this issue.

Shouldn't temp_index also be made unsigned? It certainly would make a lot of
sense to do that.

Regards,

	Hans

> 
> Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: fix it a different way
> 
> diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
> index 79a566d7defd..180a05e91497 100644
> --- a/include/media/davinci/vpbe.h
> +++ b/include/media/davinci/vpbe.h
> @@ -92,7 +92,7 @@ struct vpbe_config {
>  	struct encoder_config_info *ext_encoders;
>  	/* amplifier information goes here */
>  	struct amp_config_info *amp;
> -	int num_outputs;
> +	unsigned int num_outputs;
>  	/* Order is venc outputs followed by LCD and then external encoders */
>  	struct vpbe_output *outputs;
>  };
> 


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

* Re: [PATCH v2] media: davinci vpbe: array underflow in vpbe_enum_outputs()
  2018-05-25 13:16       ` Hans Verkuil
@ 2018-05-25 13:21         ` Dan Carpenter
  -1 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2018-05-25 13:21 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Lad, Prabhakar, Manjunath Hadli, Mauro Carvalho Chehab,
	linux-media, kernel-janitors

On Fri, May 25, 2018 at 03:16:21PM +0200, Hans Verkuil wrote:
> On 25/05/18 15:12, Dan Carpenter wrote:
> > In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
> > the problem is that temp_index can be negative.  I've made
> > cgf->num_outputs unsigned to fix this issue.
> 
> Shouldn't temp_index also be made unsigned? It certainly would make a lot of
> sense to do that.

Yeah, sure.  It doesn't make any difference in terms of runtime but it's
probably cleaner.

regards,
dan carpenter

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

* Re: [PATCH v2] media: davinci vpbe: array underflow in vpbe_enum_outputs()
@ 2018-05-25 13:21         ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2018-05-25 13:21 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Lad, Prabhakar, Manjunath Hadli, Mauro Carvalho Chehab,
	linux-media, kernel-janitors

On Fri, May 25, 2018 at 03:16:21PM +0200, Hans Verkuil wrote:
> On 25/05/18 15:12, Dan Carpenter wrote:
> > In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
> > the problem is that temp_index can be negative.  I've made
> > cgf->num_outputs unsigned to fix this issue.
> 
> Shouldn't temp_index also be made unsigned? It certainly would make a lot of
> sense to do that.

Yeah, sure.  It doesn't make any difference in terms of runtime but it's
probably cleaner.

regards,
dan carpenter


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

* Re: [PATCH v3] media: davinci vpbe: array underflow in vpbe_enum_outputs()
  2018-05-25 13:12     ` Dan Carpenter
  (?)
  (?)
@ 2018-05-29 19:54     ` Lad, Prabhakar
  -1 siblings, 0 replies; 13+ messages in thread
From: Lad, Prabhakar @ 2018-05-29 19:54 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Manjunath Hadli, Hans Verkuil, Mauro Carvalho Chehab,
	linux-media, kernel-janitors

On Mon, May 28, 2018 at 7:26 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
> the problem is that temp_index can be negative.  I've changed the types
> to unsigned to fix this issue.
>
> Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: fix it a different way
> v3: change everything to unsigned because that's the right thing to do
>     and looks nicer.
>

Acked-by: Lad, Prabhakar <prabhakar.csengg@gmail.com>

Regards,
--Prabhakar Lad

> diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
> index 79a566d7defd..180a05e91497 100644
> --- a/include/media/davinci/vpbe.h
> +++ b/include/media/davinci/vpbe.h
> @@ -92,7 +92,7 @@ struct vpbe_config {
>         struct encoder_config_info *ext_encoders;
>         /* amplifier information goes here */
>         struct amp_config_info *amp;
> -       int num_outputs;
> +       unsigned int num_outputs;
>         /* Order is venc outputs followed by LCD and then external encoders */
>         struct vpbe_output *outputs;
>  };
> diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
> index 18c035ef84cf..c6fee53bff4d 100644
> --- a/drivers/media/platform/davinci/vpbe.c
> +++ b/drivers/media/platform/davinci/vpbe.c
> @@ -126,7 +126,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
>                              struct v4l2_output *output)
>  {
>         struct vpbe_config *cfg = vpbe_dev->cfg;
> -       int temp_index = output->index;
> +       unsigned int temp_index = output->index;
>
>         if (temp_index >= cfg->num_outputs)
>                 return -EINVAL;

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

* [PATCH v3 resend] media: davinci/vpbe: array underflow in vpbe_enum_outputs()
  2018-05-17  9:05 ` Dan Carpenter
@ 2019-04-24  9:46   ` Dan Carpenter
  -1 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2019-04-24  9:46 UTC (permalink / raw)
  To: Lad, Prabhakar; +Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors

In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
the problem is that "temp_index" can be negative.  This patch changes
the types to unsigned to address this array underflow bug.

Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
---
I sent this patch last May but somehow the spam filters on the lists
must have eaten it.  I didn't get a copy from the kernel-janitors list.
The only trace I have of my original patch is that the maintainer Acked
it.  Resending.

v2: In the first version, I clamped output->index to 0-INT_MAX for every
    driver.  In v2, I only changed the vpbe.h driver header file.
v3: In v3 I changed the header and the .c file (All three versions of
    patch "worked", they just had philosophical and style issues).

 drivers/media/platform/davinci/vpbe.c | 2 +-
 include/media/davinci/vpbe.h          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 8339163a5231..4e24f5d781f4 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -104,7 +104,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
 			     struct v4l2_output *output)
 {
 	struct vpbe_config *cfg = vpbe_dev->cfg;
-	int temp_index = output->index;
+	unsigned int temp_index = output->index;
 
 	if (temp_index >= cfg->num_outputs)
 		return -EINVAL;
diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
index 5c31a7682492..f76d2f25a824 100644
--- a/include/media/davinci/vpbe.h
+++ b/include/media/davinci/vpbe.h
@@ -92,7 +92,7 @@ struct vpbe_config {
 	struct encoder_config_info *ext_encoders;
 	/* amplifier information goes here */
 	struct amp_config_info *amp;
-	int num_outputs;
+	unsigned int num_outputs;
 	/* Order is venc outputs followed by LCD and then external encoders */
 	struct vpbe_output *outputs;
 };
-- 
2.18.0

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

* [PATCH v3 resend] media: davinci/vpbe: array underflow in vpbe_enum_outputs()
@ 2019-04-24  9:46   ` Dan Carpenter
  0 siblings, 0 replies; 13+ messages in thread
From: Dan Carpenter @ 2019-04-24  9:46 UTC (permalink / raw)
  To: Lad, Prabhakar; +Cc: Mauro Carvalho Chehab, linux-media, kernel-janitors

In vpbe_enum_outputs() we check if (temp_index >= cfg->num_outputs) but
the problem is that "temp_index" can be negative.  This patch changes
the types to unsigned to address this array underflow bug.

Fixes: 66715cdc3224 ("[media] davinci vpbe: VPBE display driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: "Lad, Prabhakar" <prabhakar.csengg@gmail.com>
---
I sent this patch last May but somehow the spam filters on the lists
must have eaten it.  I didn't get a copy from the kernel-janitors list.
The only trace I have of my original patch is that the maintainer Acked
it.  Resending.

v2: In the first version, I clamped output->index to 0-INT_MAX for every
    driver.  In v2, I only changed the vpbe.h driver header file.
v3: In v3 I changed the header and the .c file (All three versions of
    patch "worked", they just had philosophical and style issues).

 drivers/media/platform/davinci/vpbe.c | 2 +-
 include/media/davinci/vpbe.h          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/platform/davinci/vpbe.c b/drivers/media/platform/davinci/vpbe.c
index 8339163a5231..4e24f5d781f4 100644
--- a/drivers/media/platform/davinci/vpbe.c
+++ b/drivers/media/platform/davinci/vpbe.c
@@ -104,7 +104,7 @@ static int vpbe_enum_outputs(struct vpbe_device *vpbe_dev,
 			     struct v4l2_output *output)
 {
 	struct vpbe_config *cfg = vpbe_dev->cfg;
-	int temp_index = output->index;
+	unsigned int temp_index = output->index;
 
 	if (temp_index >= cfg->num_outputs)
 		return -EINVAL;
diff --git a/include/media/davinci/vpbe.h b/include/media/davinci/vpbe.h
index 5c31a7682492..f76d2f25a824 100644
--- a/include/media/davinci/vpbe.h
+++ b/include/media/davinci/vpbe.h
@@ -92,7 +92,7 @@ struct vpbe_config {
 	struct encoder_config_info *ext_encoders;
 	/* amplifier information goes here */
 	struct amp_config_info *amp;
-	int num_outputs;
+	unsigned int num_outputs;
 	/* Order is venc outputs followed by LCD and then external encoders */
 	struct vpbe_output *outputs;
 };
-- 
2.18.0

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

end of thread, other threads:[~2019-04-24  9:46 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-17  9:05 [PATCH] media: v4l2-ioctl: prevent underflow in v4l_enumoutput() Dan Carpenter
2018-05-17  9:05 ` Dan Carpenter
2018-05-25  9:06 ` Hans Verkuil
2018-05-25  9:06   ` Hans Verkuil
2018-05-25 13:12   ` [PATCH v2] media: davinci vpbe: array underflow in vpbe_enum_outputs() Dan Carpenter
2018-05-25 13:12     ` Dan Carpenter
2018-05-25 13:16     ` Hans Verkuil
2018-05-25 13:16       ` Hans Verkuil
2018-05-25 13:21       ` Dan Carpenter
2018-05-25 13:21         ` Dan Carpenter
2018-05-29 19:54     ` [PATCH v3] " Lad, Prabhakar
2019-04-24  9:46 ` [PATCH v3 resend] media: davinci/vpbe: " Dan Carpenter
2019-04-24  9:46   ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.