From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C09FF20F090; Tue, 17 Jun 2025 15:41:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750174871; cv=none; b=WmJ2heMDXR6p52/TQpn4zoRPn5ZZNkGfPqE1JKsFAO0Ap6Vv3G9Y3qCJeR0zPzC9Bh+MgKBlqEOZPoo+3ni8eLRrJ/Q9Kq+hSxdC3Wz97Of9Z+tRfdOIbD9ABVzVE3RYI4DuY4Hw2VpcTDAfE5qktdDQwchBJN8MLC+GOSp5sm8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750174871; c=relaxed/simple; bh=7dQlZUQfvanAiPZ0BEhGT9k6rMBt3ckZjP7XPcGNQPA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F77bS0X6BAteEHX+M+5ZkuWHTPJXA+FivAJxELn8F7HaAiM3FL4/KURH9gsOmcy8P28PtCSkafLbQF8phQzEF7MVaamsKq4MB1ksoXvaGibuhZp/xoYK0eg3i8aBXPXVV7YvrQT+2byS4VjYvOWf6IWQwf76iAPr05i5B5ocUDA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=V9EWM2vz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="V9EWM2vz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00FF2C4CEE3; Tue, 17 Jun 2025 15:41:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750174871; bh=7dQlZUQfvanAiPZ0BEhGT9k6rMBt3ckZjP7XPcGNQPA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V9EWM2vz3dprdpzWvIGPFOL+zNRZdhQ36sDaytE24cwWoGMC8xVMAc1HzSt28US7j KNCNc+5PskEAJSyCHrdhjmxz/JqLqR15evIaGpinJVCXm9vLfjzWyNyFFHv8qGEoX3 DhMH+VoYKV9Zy+q1yb7tpI9axrRHmXBAdPEfE1FY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andy Shevchenko , Linus Walleij , Sasha Levin Subject: [PATCH 6.6 121/356] pinctrl: at91: Fix possible out-of-boundary access Date: Tue, 17 Jun 2025 17:23:56 +0200 Message-ID: <20250617152343.098836617@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250617152338.212798615@linuxfoundation.org> References: <20250617152338.212798615@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andy Shevchenko [ Upstream commit 762ef7d1e6eefad9896560bfcb9bcf7f1b6df9c1 ] at91_gpio_probe() doesn't check that given OF alias is not available or something went wrong when trying to get it. This might have consequences when accessing gpio_chips array with that value as an index. Note, that BUG() can be compiled out and hence won't actually perform the required checks. Fixes: 6732ae5cb47c ("ARM: at91: add pinctrl support") Signed-off-by: Andy Shevchenko Closes: https://lore.kernel.org/r/202505052343.UHF1Zo93-lkp@intel.com/ Link: https://lore.kernel.org/20250508200807.1384558-1-andriy.shevchenko@linux.intel.com Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/pinctrl-at91.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index d7b66928a4e50..3c09f743b68c2 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1825,12 +1825,16 @@ static int at91_gpio_probe(struct platform_device *pdev) struct at91_gpio_chip *at91_chip = NULL; struct gpio_chip *chip; struct pinctrl_gpio_range *range; + int alias_idx; int ret = 0; int irq, i; - int alias_idx = of_alias_get_id(np, "gpio"); uint32_t ngpio; char **names; + alias_idx = of_alias_get_id(np, "gpio"); + if (alias_idx < 0) + return alias_idx; + BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips)); if (gpio_chips[alias_idx]) return dev_err_probe(dev, -EBUSY, "%d slot is occupied.\n", alias_idx); -- 2.39.5