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 X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBA30C433EF for ; Sat, 11 Sep 2021 22:06:33 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id F3A6F60F51 for ; Sat, 11 Sep 2021 22:06:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F3A6F60F51 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D5771838B4; Sun, 12 Sep 2021 00:06:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=sholland.org header.i=@sholland.org header.b="QdkeuRvd"; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b="r7EKqdVK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4925D838A8; Sun, 12 Sep 2021 00:06:04 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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 03D488389C for ; Sun, 12 Sep 2021 00:05:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=sholland.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=samuel@sholland.org Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 4B9F95C00C2; Sat, 11 Sep 2021 18:05:58 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 11 Sep 2021 18:05:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=eoG2DWbtTeege acPWIvF9d/sKtqhFdfHTEcQXAsOe6g=; b=QdkeuRvdj/RU8tWETiPZVpjMz3avs pMU9541iH+QkjtN2dG6JLmdZ+hHstoE5T9a38JRnCiv46rp1zpzugQsqbiROTlD0 PmdVrgMVk5Ed0KZwFwp8ZglArl390O6SCG4y5CM+/8ZLpcwjqmk65NWpMgHQ+H1T o4ol9sa/wLKYAx95ebzISayR/qIiny/EKrboKoyQyWH9Qw4nvWRi6GbjVwgFrL17 C/G1HVlvrnRdHU7IgKcflTIn0nDlYO5gDt4qyeDlomgZm8kUjZ6+Ndfm+w9XOjmA 9tSwNdYdNuflftxzHGYmdDO/u744+HuS01O8ZSIrSxzBit9XIcXqoV9Pg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=eoG2DWbtTeegeacPWIvF9d/sKtqhFdfHTEcQXAsOe6g=; b=r7EKqdVK MbofPncHG7j/Fmsc+N/gmRzzAuHBncF1eg/F+MohC/em5rl3Q2XHpSdauc4MKuX0 Tkqh56dokV+xrf4KoXtBCwk0TyTtWQ483eA5DkDKRbDN4mTxLY6b8k7nc37w84Qj /Qx/S/qwwTohj3dS6lp3NKs0pSTuxZxXit3F5Gx3SMKTEEJfdxq8MfzTSoaSvtN8 cRHPc1MffsJh0HZpnwzW6cvfbjOUSR6k6a3cDxIh1jChhZgEPWaYF4+4Ac9DwI5l LkmrN+1Znpo6uDHnu7MeUdYFub2+sbDp8QWhCtCGXD6ZQk4yKL72ZlQtoGQSoZhe FV3Ra4npXJTxcg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudeggedgtddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 11 Sep 2021 18:05:57 -0400 (EDT) From: Samuel Holland To: u-boot@lists.denx.de Cc: Samuel Holland , Dario Binacchi , Jean-Jacques Hiblot , Patrick Delaunay , Pratyush Yadav , Simon Glass Subject: [PATCH 1/3] gpio: Verify validity of pin offsets when looking up names Date: Sat, 11 Sep 2021 17:05:51 -0500 Message-Id: <20210911220553.9427-2-samuel@sholland.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210911220553.9427-1-samuel@sholland.org> References: <20210911220553.9427-1-samuel@sholland.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Translation of a pin name to a device+offset should fail if the offset is larger than the number of pins in the GPIO bank. Signed-off-by: Samuel Holland --- drivers/gpio/gpio-uclass.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index 8c77777dbe3..57e87960ee4 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -140,7 +140,8 @@ int dm_gpio_lookup_name(const char *name, struct gpio_desc *desc) if (!strncasecmp(name, uc_priv->bank_name, len)) { if (!strict_strtoul(name + len, 10, &offset)) - break; + if (offset < uc_priv->gpio_count) + break; } /* -- 2.31.1