]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
regulator: fixed: fix GPIO descriptor leak on register failure
authorHaotian Zhang <vulab@iscas.ac.cn>
Tue, 28 Oct 2025 17:28:28 +0000 (01:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Dec 2025 11:45:18 +0000 (12:45 +0100)
commit31a148f1d06f7dce465effba2277f6dbf655c28e
tree0e49f39a935f1e708bae4beb2ae0d9c4bee23e53
parent81e24e73ca7383ba4b2c1ee49f0f0bfce3d17a48
regulator: fixed: fix GPIO descriptor leak on register failure

[ Upstream commit 636f4618b1cd96f6b5a2b8c7c4f665c8533ecf13 ]

In the commit referenced by the Fixes tag,
devm_gpiod_get_optional() was replaced by manual
GPIO management, relying on the regulator core to release the
GPIO descriptor. However, this approach does not account for the
error path: when regulator registration fails, the core never
takes over the GPIO, resulting in a resource leak.

Add gpiod_put() before returning on regulator registration failure.

Fixes: 5e6f3ae5c13b ("regulator: fixed: Let core handle GPIO descriptor")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
Link: https://patch.msgid.link/20251028172828.625-1-vulab@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/regulator/fixed.c