diff mbox series

AW: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing

Message ID cb14e57edc1c4f3a81b0aef6f1099b9c@bfs.de (mailing list archive)
State Superseded, archived
Headers show
Series AW: [PATCH][V2] backlight: sky81452: insure while loop does not allow negative array indexing | expand

Commit Message

Walter Harms Feb. 27, 2020, 11:15 a.m. UTC
hi all,
i would suggest converting this in to a more common for() loop.
Programmers are bad in counting backwards. that kind of bug is 
common.

re,
 wh
diff mbox series

Patch

diff --git a/drivers/video/backlight/sky81452-backlight.c b/drivers/video/backlight/sky81452-backlight.c
index 2355f00f5773..f456930ce78e 100644
--- a/drivers/video/backlight/sky81452-backlight.c
+++ b/drivers/video/backlight/sky81452-backlight.c
@@ -200,7 +200,7 @@  static struct sky81452_bl_platform_data *sky81452_bl_parse_dt(
                }

                pdata->enable = 0;
-               while (--num_entry)
+               while (--num_entry >= 0)
                        pdata->enable |= (1 << sources[num_entry]);
 
              int i;