From: Pali Rohár Date: Mon, 17 Jan 2022 15:38:39 +0000 (+0100) Subject: pci: Add checks for valid cmdline arguments X-Git-Tag: v2022.07~206^2~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6850a5a8e24fc2345348dd9a160abd7a8e7f1b72;p=platform%2Fkernel%2Fu-boot.git pci: Add checks for valid cmdline arguments Currently pci command ignores invalid cmdline arguments and do something. Add checks that all passed arguments were processed. Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese --- diff --git a/cmd/pci.c b/cmd/pci.c index 96e6fbd..ca8f6f5 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) {