Skip to content

Commit 2f88425

Browse files
ISCAS-Vulabgroeck
authored andcommitted
hwmon: sy7636a: Fix regulator_enable resource leak on error path
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: de34a40 ("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>
1 parent a4d01f3 commit 2f88425

1 file changed

Lines changed: 1 addition & 6 deletions

File tree

drivers/hwmon/sy7636a-hwmon.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,13 @@ static const struct hwmon_chip_info sy7636a_chip_info = {
6666
static int sy7636a_sensor_probe(struct platform_device *pdev)
6767
{
6868
struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
69-
struct regulator *regulator;
7069
struct device *hwmon_dev;
7170
int err;
7271

7372
if (!regmap)
7473
return -EPROBE_DEFER;
7574

76-
regulator = devm_regulator_get(&pdev->dev, "vcom");
77-
if (IS_ERR(regulator))
78-
return PTR_ERR(regulator);
79-
80-
err = regulator_enable(regulator);
75+
err = devm_regulator_get_enable(&pdev->dev, "vcom");
8176
if (err)
8277
return err;
8378

0 commit comments

Comments
 (0)