[PATCH 3/4] pci: Add checks for valid cmdline arguments
Stefan Roese
sr at denx.de
Tue Jan 25 16:53:21 CET 2022
On 1/17/22 16:38, Pali Rohár wrote:
> 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>
Reviewed-by: Stefan Roese <sr at denx.de>
Thanks,
Stefan
> ---
> 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) {
Viele Grüße,
Stefan Roese
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de
More information about the U-Boot
mailing list