Message ID | 20200115111706.4762-1-pankaj.bansal@nxp.com |
---|---|
State | Accepted |
Commit | 71c8fb3e3a3e79c98d305b49ea46ae92332c3f20 |
Headers | show |
Series | [v2] board: fsl: lx2160a: Fix the loop in board_fix_fdt function | expand |
>-----Original Message----- >From: Pankaj Bansal <pankaj.bansal at nxp.com> >Sent: Wednesday, January 15, 2020 11:27 AM >To: Priyanka Jain <priyanka.jain at nxp.com>; Meenakshi Aggarwal ><meenakshi.aggarwal at nxp.com> >Cc: u-boot at lists.denx.de; Pankaj Bansal <pankaj.bansal at nxp.com> >Subject: [PATCH v2] board: fsl: lx2160a: Fix the loop in board_fix_fdt function > >Fix 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> >--- patch applied(after updating description) in u-boot-fsl-qoriq/master -priyankajain
diff --git a/board/freescale/lx2160a/lx2160a.c b/board/freescale/lx2160a/lx2160a.c index e5b7fec9a4..e1edd9225c 100644 --- a/board/freescale/lx2160a/lx2160a.c +++ b/board/freescale/lx2160a/lx2160a.c @@ -131,7 +131,7 @@ int board_fix_fdt(void *fdt) { "ccsr", "dbi" }, { "pf_ctrl", "ctrl" } }; - int off = -1, i; + int off = -1, i = 0; if (IS_SVR_REV(get_svr(), 1, 0)) return 0; @@ -148,7 +148,7 @@ 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++) { + 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 +164,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);
Fix 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> --- Notes: V2: - assigned value to i when declared : suggested by Jagdish - removed mention of "for loop" from commit header and description becuase we have replaced for loop with while loop : suggested by Jagdish board/freescale/lx2160a/lx2160a.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)