Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795036550; b=kHu/0zoW5XyMTMxomTwrPkBbFGVNi1pbWvSNAUDRWX1C+URNtY78QwSygXypArndKH4K zASn6UpVUA0WyZojFYnyQn2BJmmz8s/cnOtBhrt8OmD4LoXJoIkpise5rFbqrabxC5x/X Z3yHgoP2KM2c2+i6v9GG2cus3qeFGqj4gqPkHL5kZ/SPCLz9YpOlcYpBlKr5pc6+tpwSI +tQiRBXKs+pDSPc/1bcbrndjbPdGJXZGow4EgJ5mRLvisXiduR74JnII4Oq1ncXKAVELO vqyUT2eFIA0AtpILccSlSekgN0Tl7LRT18G5NEjcBUORi6u3pZFUgg9dqUSTH7npDxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795036550; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=4V/l3ncRbwOh4WGnxxP/mEz67l288gVAQFOrm5SK0hk=; b=0E5X46276FhQEmYf+/vRblUPwuF8pPI6UeQ8Z03RCmHTcec75FurWXF+W8bxdZUePMBw AwE8LIhmHwO3FC6rv1s9v2hE6NnlewW4ThYgZ7BK/bhvLbq+QUvLvZWP9mj40DZCe9gZw G37F9DpEZrAPfWn8AReCiuxKk6EFUiP+4Ma8rBmnXtlPjrWhVEE18toPJzTShGzPq8qkd VgMsjSqjak62x8013xcxBkjMBzLeQ3QU+63a8zywkFnOYcjaz+6gAMn48tBHAsyjSQCQM n6nrudGkyChKbBuF5x9v4VsBCtJObYM4QDcTp9VTAm65ZpVufVbJHSmFedQtjFIjSWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b="N/NUqQPq"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC46B60A2601; Wed, 18 Nov 2026 21:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=N/NUqQPq Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF0221F000C4; Wed, 18 Nov 2026 21:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795036550; bh=4V/l3ncRbwOh4WGnxxP/mEz67l288gVAQFOrm5SK0hk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N/NUqQPqfDJhLRWYW0qzMGtrkm+PXnTclsFfXp8a2AC9vpSNpC4AthXb8Pcobo1Me /atX0WQZE3PgsSYm4qELj/8hjaHntLw5OyEoN8vdRzfOcI1EMdfLbVx/ZXmaAXZp8B COSHSA+nJM5yxP4MN2921LFmu743ZgNv2pqVfdS4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ma Ke , Antonio Borneo , Linus Walleij , Sasha Levin Subject: [PATCH 6.6 1099/3318] pinctrl: stm32: Fix fwnode reference leak in stm32_gpiolib_register_bank() Date: Wed, 18 Nov 2026 15:28:41 +0100 Message-ID: <20261118150352.950137677@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ma Ke [ Upstream commit 54c66b5e47a9b10cbf4a1efe9b01301b7ffee205 ] stm32_gpiolib_register_bank() walks the "gpio-ranges" property with fwnode_property_get_reference_args(). As documented in drivers/base/property.c: * The caller is responsible for calling fwnode_handle_put() on the * returned @args->fwnode pointer. The returned reference is never put. The function calls the helper twice, once directly and then repeatedly in a while loop, and each call overwrites args, so only the last reference is even reachable and all the earlier ones are leaked for good. Put the reference as soon as args.args[] has been consumed, both for the initial call and for every iteration of the loop. Found by code review. Cc: stable@vger.kernel.org Fixes: bb949ed9b16b ("pinctrl: stm32: Switch to use for_each_gpiochip_node() helper") Signed-off-by: Ma Ke Reviewed-by: Antonio Borneo Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/pinctrl/stm32/pinctrl-stm32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c index bfc10cf9ab975..eace8153c4ab0 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -1332,8 +1332,12 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, struct fwnode /* get the last defined gpio line (offset + nb of pins) */ npins = args.args[0] + args.args[2]; - while (!fwnode_property_get_reference_args(fwnode, "gpio-ranges", NULL, 3, ++i, &args)) + fwnode_handle_put(args.fwnode); + + while (!fwnode_property_get_reference_args(fwnode, "gpio-ranges", NULL, 3, ++i, &args)) { npins = max(npins, (int)(args.args[0] + args.args[2])); + fwnode_handle_put(args.fwnode); + } } else { bank_nr = pctl->nbanks; bank->gpio_chip.base = bank_nr * STM32_GPIO_PINS_PER_BANK; -- 2.53.0