mirror of
https://github.com/u-boot/u-boot.git
synced 2024-11-24 12:44:23 +08:00
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>
This commit is contained in:
parent
9009798df2
commit
b922a5f94d
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user