Re: REGRESSION: [RESEND PATCH v3 1/4] backlight: pwm_bl: linear interpolation between brightness-levels

From: Daniel Thompson
Date: Sun Jul 15 2018 - 03:57:46 EST


On Sat, Jul 14, 2018 at 03:08:17PM +0000, Marcel Ziswiler wrote:
> On Mon, 2018-04-09 at 10:33 +0200, Enric Balletbo i Serra wrote:
> > diff --git a/drivers/video/backlight/pwm_bl.c
> > b/drivers/video/backlight/pwm_bl.c
> > index 8e3f1245f5c5..f0a108ab570a 100644
> > --- a/drivers/video/backlight/pwm_bl.c
> > +++ b/drivers/video/backlight/pwm_bl.c
> > @@ -147,7 +147,11 @@ static int pwm_backlight_parse_dt(struct device
> > *dev,
> > struct platform_pwm_backlight_data
> > *data)
> > {
> > struct device_node *node = dev->of_node;
> > + unsigned int num_levels = 0;
> > + unsigned int levels_count;
> > + unsigned int num_steps;

num_steps is not initialized...


> > struct property *prop;
> > + unsigned int *table;
> > int length;
> > u32 value;
> > int ret;
> > @@ -167,6 +171,7 @@ static int pwm_backlight_parse_dt(struct device
> > *dev,
> > /* read brightness levels from DT property */
> > if (data->max_brightness > 0) {
> > size_t size = sizeof(*data->levels) * data-
> > >max_brightness;
> > + unsigned int i, j, n = 0;
> >
> > data->levels = devm_kzalloc(dev, size, GFP_KERNEL);
> > if (!data->levels)
> > @@ -184,6 +189,84 @@ static int pwm_backlight_parse_dt(struct device
> > *dev,
> > return ret;
> >
> > data->dft_brightness = value;
> > +
> > + /*
> > + * This property is optional, if is set enables
> > linear
> > + * interpolation between each of the values of
> > brightness levels
> > + * and creates a new pre-computed table.
> > + */
> > + of_property_read_u32(node, "num-interpolated-steps",
> > + &num_steps);

... this is not guaranteed to initialized num_steps ...

> > +
> > + /*
> > + * Make sure that there is at least two entries in
> > the
> > + * brightness-levels table, otherwise we can't
> > interpolate
> > + * between two points.
> > + */
> > + if (num_steps) {

... and we make a decision on it here.

Marcel: Can you try the following quick fix? It's untested on my side
but very simple...