[PATCH 3/4] pci: Add checks for valid cmdline arguments
Pali Rohár
pali at kernel.org
Mon Jan 17 16:38:39 CET 2022
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 at kernel.org>
---
cmd/pci.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/cmd/pci.c b/cmd/pci.c
index 53edf0d90010..8d2c0c4b43dd 100644
--- 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) {
--
2.20.1
More information about the U-Boot
mailing list