diff mbox series

board: fsl: lx2160a: Fix the for loop in board_fix_fdt

Message ID 20200113174902.23886-1-pankaj.bansal@nxp.com
State New
Headers show
Series board: fsl: lx2160a: Fix the for loop in board_fix_fdt | expand

Commit Message

Pankaj Bansal Jan. 13, 2020, 12:28 p.m. UTC
Fix for loop in board_fix_fdt that erroneously increments the counter
in all cases. the counter should be incremented only if a matching string
has been found.

Fixes: 5d535aa40b ("board: fsl: lx2160a: implement board_fix_fdt")

Signed-off-by: Pankaj Bansal <pankaj.bansal at nxp.com>
---
 board/freescale/lx2160a/lx2160a.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c
index e5b7fec9a4..0950f5064b 100644
--- a/board/freescale/lx2160a/lx2160a.c
+++ b/board/freescale/lx2160a/lx2160a.c
@@ -148,7 +148,8 @@  int board_fix_fdt(void *fdt)
 
 		reg_name = reg_names;
 		remaining_names_len = names_len - (reg_name - reg_names);
-		for (i = 0; (i < ARRAY_SIZE(reg_names_map)) && names_len; i++) {
+		i = 0;
+		while ((i < ARRAY_SIZE(reg_names_map)) && remaining_names_len) {
 			old_name_len = strlen(reg_names_map[i].old_str);
 			new_name_len = strlen(reg_names_map[i].new_str);
 			if (memcmp(reg_name, reg_names_map[i].old_str,
@@ -164,6 +165,7 @@  int board_fix_fdt(void *fdt)
 				       new_name_len);
 				names_len -= old_name_len;
 				names_len += new_name_len;
+				i++;
 			}
 
 			reg_name = memchr(reg_name, '\0', remaining_names_len);