[libcamera-devel,3/4] ipa: raspberrypi: fix access to uninitialized variables
diff mbox series

Message ID 20201007110743.55561-4-tomi.valkeinen@iki.fi
State Superseded
Headers show
Series
  • ipa: raspberrypi: fix uninit variables
Related show

Commit Message

Tomi Valkeinen Oct. 7, 2020, 11:07 a.m. UTC
Set span_r and span_b to -1 so that when they are passed to Pwl::Eval()
they won't cause access to uninitialized memory.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
---
 src/ipa/raspberrypi/controller/rpi/awb.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kieran Bingham Oct. 7, 2020, 12:41 p.m. UTC | #1
Hi Tomi,

On 07/10/2020 12:07, Tomi Valkeinen wrote:
> Set span_r and span_b to -1 so that when they are passed to Pwl::Eval()
> they won't cause access to uninitialized memory.
> 

This matches the documentation of Eval at
src/ipa/raspberrypi/controller/pwl.hpp:
>         // Evaluate Pwl, optionally supplying an initial guess for the
>         // "span". The "span" may be optionally be updated.  If you want to know
>         // the "span" value but don't have an initial guess you can set it to
>         // -1.

So I believe this is correct.

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


> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
> ---
>  src/ipa/raspberrypi/controller/rpi/awb.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp
> index a5536e4..469d0e5 100644
> --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
> +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
> @@ -430,7 +430,7 @@ double Awb::coarseSearch(Pwl const &prior)
>  
>  void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior)
>  {
> -	int span_r, span_b;
> +	int span_r = -1, span_b = -1;
>  	config_.ct_r.Eval(t, &span_r);
>  	config_.ct_b.Eval(t, &span_b);
>  	double step = t / 10 * config_.coarse_step * 0.1;
>
David Plowman Oct. 7, 2020, 1:07 p.m. UTC | #2
Hi Tomi

On Wed, 7 Oct 2020 at 13:41, Kieran Bingham
<kieran.bingham@ideasonboard.com> wrote:
>
> Hi Tomi,
>
> On 07/10/2020 12:07, Tomi Valkeinen wrote:
> > Set span_r and span_b to -1 so that when they are passed to Pwl::Eval()
> > they won't cause access to uninitialized memory.
> >
>
> This matches the documentation of Eval at
> src/ipa/raspberrypi/controller/pwl.hpp:
> >         // Evaluate Pwl, optionally supplying an initial guess for the
> >         // "span". The "span" may be optionally be updated.  If you want to know
> >         // the "span" value but don't have an initial guess you can set it to
> >         // -1.
>
> So I believe this is correct.
>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>

Mea culpa. Thanks very much!

Reviewed-by: David Plowman <david.plowman@raspberrypi.com>

Best regards
David

>
>
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
> > ---
> >  src/ipa/raspberrypi/controller/rpi/awb.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp
> > index a5536e4..469d0e5 100644
> > --- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
> > +++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
> > @@ -430,7 +430,7 @@ double Awb::coarseSearch(Pwl const &prior)
> >
> >  void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior)
> >  {
> > -     int span_r, span_b;
> > +     int span_r = -1, span_b = -1;
> >       config_.ct_r.Eval(t, &span_r);
> >       config_.ct_b.Eval(t, &span_b);
> >       double step = t / 10 * config_.coarse_step * 0.1;
> >
>
> --
> Regards
> --
> Kieran

Patch
diff mbox series

diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp
index a5536e4..469d0e5 100644
--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp
+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp
@@ -430,7 +430,7 @@  double Awb::coarseSearch(Pwl const &prior)
 
 void Awb::fineSearch(double &t, double &r, double &b, Pwl const &prior)
 {
-	int span_r, span_b;
+	int span_r = -1, span_b = -1;
 	config_.ct_r.Eval(t, &span_r);
 	config_.ct_b.Eval(t, &span_b);
 	double step = t / 10 * config_.coarse_step * 0.1;