From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AF770C433F5 for ; Tue, 25 Jan 2022 15:53:32 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1DC6983809; Tue, 25 Jan 2022 16:53:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1643126011; bh=VkESPuF04sDeZW3+G2SXYs98ZrJFmIufd/YAEaRNsKc=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=NeSiHbx+F0Iyl0ue1uWOohrU/Ao+NVQ1JQP2ITMv73RBVcReID1L2bnWoGPHvyZZl x7nmW+uOo69WVCndAh8mhfKLaqdpmFlDjPQ9o8aZ95E6TODsXhabxBCIYPnkbmtjnP 8rsKv6bUaTUEOWfZ58otP73xYpDrUA3hi0OPVB2lArNZ5mo/PLOnmNQZ5aLQcfkeDv nUqcAcoJszYxtrvfzNUiYqdruob+FtisFlgYbau3W0EK1udM7I0kb6IRTz4NmBA+u2 ckjl4n7skQsIaa9hop+N6pJM8JSMgB7f9Dtiopgm04sepIDoszF5NRJvK0hnWj8VKq WhCixFEX3WSbg== Received: by phobos.denx.de (Postfix, from userid 109) id 16B418331E; Tue, 25 Jan 2022 16:53:29 +0100 (CET) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [91.198.250.252]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3BB1D83815 for ; Tue, 25 Jan 2022 16:53:26 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp202.mailbox.org (unknown [91.198.250.118]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4Jjrx14nSCz9sl6; Tue, 25 Jan 2022 16:53:25 +0100 (CET) Message-ID: Date: Tue, 25 Jan 2022 16:53:21 +0100 MIME-Version: 1.0 Subject: Re: [PATCH 3/4] pci: Add checks for valid cmdline arguments Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , Bin Meng , Simon Glass , =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de References: <20220117153840.31173-1-pali@kernel.org> <20220117153840.31173-4-pali@kernel.org> From: Stefan Roese In-Reply-To: <20220117153840.31173-4-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean 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 Reviewed-by: Stefan Roese 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@denx.de