Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

regulator: fixed: fix GPIO descriptor leak on register failure

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>

authored by

Haotian Zhang and committed by
Mark Brown
636f4618 6146a0f1

+1
+1
drivers/regulator/fixed.c
··· 334 334 ret = dev_err_probe(&pdev->dev, PTR_ERR(drvdata->dev), 335 335 "Failed to register regulator: %ld\n", 336 336 PTR_ERR(drvdata->dev)); 337 + gpiod_put(cfg.ena_gpiod); 337 338 return ret; 338 339 } 339 340