]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
pci: Add checks for valid cmdline arguments
authorPali Rohár <pali@kernel.org>
Mon, 17 Jan 2022 15:38:39 +0000 (16:38 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 28 Jan 2022 22:58:41 +0000 (17:58 -0500)
Currently pci command ignores invalid cmdline arguments and do something.
Add checks that all passed arguments were processed.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
cmd/pci.c

index 96e6fbd5d0297457af3e7df48e06bbc25de7e212..ca8f6f5b4ca41d9f0be907afd28376144c95a331 100644 (file)
--- a/cmd/pci.c
+++ b/cmd/pci.c
@@ -523,7 +523,12 @@ static int do_pci(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                        }
                        if (argc > 2 || (argc > 1 && cmd != 'r' && argv[1][0] != 's')) {
                                busnum = hextoul(argv[argc - 1], NULL);
+                               argc--;
                        }
+                       if (cmd == 'r' && argc > 2)
+                               goto usage;
+                       else if (cmd != 'r' && (argc > 2 || (argc == 2 && argv[1][0] != 's')))
+                               goto usage;
                }
                ret = uclass_get_device_by_seq(UCLASS_PCI, busnum, &bus);
                if (ret) {