[U-Boot] [PATCH] cmd: ethsw: Fix out-of-bounds error

York Sun york.sun at nxp.com
Tue Jun 13 16:50:41 UTC 2017


The for loop in cmd_keywords_opt_check() seems to use wrong array to
set boundary, reported by Coverity analysis.

Signed-off-by: York Sun <york.sun at nxp.com>
CC: Joe Hershberger <joe.hershberger at ni.com>
CC: Tom Rini <trini at konsulko.com>
CC: Prabhakar Kushwaha <prabhakar.kushwaha at nxp.com>
---

 cmd/ethsw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/ethsw.c b/cmd/ethsw.c
index 491cb8e..b600965 100644
--- a/cmd/ethsw.c
+++ b/cmd/ethsw.c
@@ -915,7 +915,7 @@ static void cmd_keywords_opt_check(const struct ethsw_command_def *parsed_cmd,
 	 * check if our command's optional keywords match the optional
 	 * keywords of an available command
 	 */
-	for (i = 0; i < ARRAY_SIZE(ethsw_cmd_def); i++) {
+	for (i = 0; i < ARRAY_SIZE(cmd_opt_def); i++) {
 		keyw_opt_matched = 0;
 		cmd_keyw_p = &parsed_cmd->cmd_to_keywords[keyw_opt_matched];
 		cmd_keyw_opt_p = &cmd_opt_def[i].cmd_keyword[keyw_opt_matched];
-- 
2.7.4



More information about the U-Boot mailing list