Message ID | 20180525131239.45exrwgxr2f3kb57@kili.mountain (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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; > }; >
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
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;
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; };
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