lkml.org 
[lkml]   [2018]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] backlight: pwm_bl: Fix uninitialized variable
Date
Currently, if the DT does not define num-interpolated-steps then
num_steps is undefined and the interpolation code will deploy randomly.
Fix this.

Fixes: 573fe6d1c25c ("backlight: pwm_bl: Linear interpolation between
brightness-levels")
Reported-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
---
drivers/video/backlight/pwm_bl.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/video/backlight/pwm_bl.c b/drivers/video/backlight/pwm_bl.c
index 9ee4c1b735b2..e3c22b79fbcd 100644
--- a/drivers/video/backlight/pwm_bl.c
+++ b/drivers/video/backlight/pwm_bl.c
@@ -299,15 +299,14 @@ static int pwm_backlight_parse_dt(struct device *dev,
* 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);
-
- /*
- * 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) {
+ if ((of_property_read_u32(node, "num-interpolated-steps",
+ &num_steps) == 0) && 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 (data->max_brightness < 2) {
dev_err(dev, "can't interpolate\n");
return -EINVAL;
--
2.17.1
\
 
 \ /
  Last update: 2018-07-16 23:04    [W:0.167 / U:1.864 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site