]> git.sur5r.net Git - u-boot/commitdiff
cmd: ethsw: Fix out-of-bounds error
authorYork Sun <york.sun@nxp.com>
Tue, 13 Jun 2017 16:50:41 +0000 (09:50 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 16 Jun 2017 14:11:42 +0000 (10:11 -0400)
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@nxp.com>
CC: Joe Hershberger <joe.hershberger@ni.com>
CC: Tom Rini <trini@konsulko.com>
CC: Prabhakar Kushwaha <prabhakar.kushwaha@nxp.com>
Reported-by: Coverity (CID: 163251)
Reviewed-by: Tom Rini <trini@konsulko.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
cmd/ethsw.c

index 491cb8eac385ed8ecf44ab6a2f46ab6bf57a59f9..b600965e8ad43a4764b519e5b89b8be1714dd17b 100644 (file)
@@ -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];