diff options
author | Peter Tyser <ptyser@xes-inc.com> | 2015-02-03 13:18:49 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-02-12 10:35:29 -0700 |
commit | b922a5f94d960b0464f81b439c34707071095565 (patch) | |
tree | 6ffcf7e124123b82664cac9b36f4cd849b30b06e /common | |
parent | 9009798df20f60fd53679b537fcb4df3460b7cf8 (diff) | |
download | u-boot-imx-b922a5f94d960b0464f81b439c34707071095565.zip u-boot-imx-b922a5f94d960b0464f81b439c34707071095565.tar.gz u-boot-imx-b922a5f94d960b0464f81b439c34707071095565.tar.bz2 |
dm: Prevent "demo hello" and "demo status" segfaults
Segfaults can occur when a mandatory argument is not provided to
"demo hello" and "demo status". Eg:
=> demo hello
Segmentation fault (core dumped)
Add a check to ensure all required arguments are provided.
Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_demo.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/common/cmd_demo.c b/common/cmd_demo.c index bcb34d9..8a10bdf 100644 --- a/common/cmd_demo.c +++ b/common/cmd_demo.c @@ -97,7 +97,9 @@ static int do_demo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ARRAY_SIZE(demo_commands)); argc -= 2; argv += 2; - if (!demo_cmd || argc > demo_cmd->maxargs) + + if ((!demo_cmd || argc > demo_cmd->maxargs) || + ((demo_cmd->name[0] != 'l') && (argc < 1))) return CMD_RET_USAGE; if (argc) { |