From 6850a5a8e24fc2345348dd9a160abd7a8e7f1b72 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pali=20Roh=C3=A1r?= Date: Mon, 17 Jan 2022 16:38:39 +0100 Subject: [PATCH] pci: Add checks for valid cmdline arguments MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- cmd/pci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/pci.c b/cmd/pci.c index 96e6fbd5d0..ca8f6f5b4c 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.39.5