[PATCH 1/4] video/backlight-pwm: fixed a loop index going out of range.

iw3gtf at arcor.de iw3gtf at arcor.de
Thu Jul 14 07:17:15 PDT 2016


In the function pwm_backlight_parse_dt() the last iteration of the for
loop accessed memory past the end of the array 'pwm_backlight->levels[]'
because of a wrong test ( '<=' instead of '<').
---
 drivers/video/backlight-pwm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/backlight-pwm.c b/drivers/video/backlight-pwm.c
index 91435f8..3024ec6 100644
--- a/drivers/video/backlight-pwm.c
+++ b/drivers/video/backlight-pwm.c
@@ -150,7 +150,7 @@ static int pwm_backlight_parse_dt(struct device_d *dev,
 		if (ret < 0)
 			return ret;
 
-		for (i = 0; i <=  pwm_backlight->backlight.brightness_max; i++)
+		for (i = 0; i < pwm_backlight->backlight.brightness_max; i++)
 			if (pwm_backlight->levels[i] > pwm_backlight->scale)
 				pwm_backlight->scale = pwm_backlight->levels[i];
 
-- 
2.9.1




More information about the barebox mailing list