From mboxrd@z Thu Jan 1 00:00:00 1970 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=1795045572; b=Co5CODwB7shc0Xzvi+Fp6R33AhMc+HUUPYsJkch1hilt3+1YM3cjpEaDdk9mwLmfK1Mc /wH/Tp4VP/9Nq3kLC15NUnd4RYrelEubwmJYMyFZiKjIfpZijLrbkW1Uqf1ZoUaVFbaGu QiwfsT4ZDCaCMinPB0IZYew213k/W1mqejCngDxpneLeglkF6K4dLRiV9N5sLDLbnA3Lg FNbnRuij9wFIAHMCzPT1eKcS7R6UlPUYm4t299EuZrYSattfJZSajEbgy6O2fRqFDvPxa EOhhpMUjGuxAYEeDCzPQKdNSuNn4b/9lBjUySRSLtqVYrypkLWtQQ2iI5I8gC0eEbww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795045572; 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=inJJy32N48Lw6/9ojFtCWHdo0ASdAUTTyT1MLuW0fq8=; b=mdOwCFMskJUeezpZlUna6A/7O9Dytk2AMteftBqX2/UQPBxRpNXxjr1EYIjzG42YcAAf jZb/CAOtmUl1fovIpupsXtunP+bE7HsL1Fl2BfphCG0XztEGgD+4+ifaUVk8PJgLV6oPq rnoT4n0BjbcDvnFd7TLh4P/3/BF8v5tIkAHZtzsZWpAxMaHRzMtx+YREgPZHWo9JFhO+h 1hnsYAwZ8On8v7R8wPR1K3vc6ZlVWo83A4rj24be5TXkzzXHhpeouqBleXTSS6sXDK/Dn qdPkJbl3q9qb3J3GuUDREfw/QtoiKg1vGTAdDrh5v0jQogkeDvq7C/OmXXZoBOqHA1Q== 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="PBW0/bkI"; 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 7DB68606A320; Wed, 18 Nov 2026 23:46:12 +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=PBW0/bkI Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE9B11F000C4; Wed, 18 Nov 2026 23:46:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795045572; bh=inJJy32N48Lw6/9ojFtCWHdo0ASdAUTTyT1MLuW0fq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PBW0/bkIx9dNxz6ZXZagKDV+3NZnaX7t3Wp/Z9zaa445kGH1zpKr+yIKtpL6DaQTY 4AAhsE815d/Tq4I2NU+2TH6NqaYOcJWvCBGizA1DLlfyk4JwbqaS8KlSZKOjx/9de1 yGWRmaMi1UWP8vD2tE6bX765vFPGRwm4Y50ldx1E= 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.1 0944/2857] pinctrl: stm32: Fix fwnode reference leak in stm32_gpiolib_register_bank() Date: Wed, 18 Nov 2026 15:32:58 +0100 Message-ID: <20261118150235.596644769@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150201.293410965@linuxfoundation.org> References: <20261118150201.293410965@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 988db6fe1174c..19ad91104cda6 100644 --- a/drivers/pinctrl/stm32/pinctrl-stm32.c +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c @@ -1331,8 +1331,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