mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-05 06:01:26 +02:00
hwmon: sy7636a: Fix regulator_enable resource leak on error path
[ Upstream commit2f88425ef5] In sy7636a_sensor_probe(), regulator_enable() is called but if devm_hwmon_device_register_with_info() fails, the function returns without calling regulator_disable(), leaving the regulator enabled and leaking the reference count. Switch to devm_regulator_get_enable() to automatically manage the regulator resource. Fixes:de34a40532("hwmon: sy7636a: Add temperature driver for sy7636a") Suggested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Link: https://lore.kernel.org/r/20251126162602.2086-1-vulab@iscas.ac.cn Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4acd1dd5a1
commit
eb02575c8b
@@ -66,18 +66,13 @@ static const struct hwmon_chip_info sy7636a_chip_info = {
|
||||
static int sy7636a_sensor_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
||||
struct regulator *regulator;
|
||||
struct device *hwmon_dev;
|
||||
int err;
|
||||
|
||||
if (!regmap)
|
||||
return -EPROBE_DEFER;
|
||||
|
||||
regulator = devm_regulator_get(&pdev->dev, "vcom");
|
||||
if (IS_ERR(regulator))
|
||||
return PTR_ERR(regulator);
|
||||
|
||||
err = regulator_enable(regulator);
|
||||
err = devm_regulator_get_enable(&pdev->dev, "vcom");
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user