lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d89fad76-999a-4486-ae77-cb2b17c29bc2@roeck-us.net>
Date: Wed, 26 Nov 2025 07:45:02 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Haotian Zhang <vulab@...as.ac.cn>,
 Alistair Francis <alistair@...stair23.me>
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] hwmon: sy7636a: Fix regulator_enable resource leak on
 error path

On 11/26/25 02:54, Haotian Zhang wrote:
> 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.
> 
> Add regulator_disable() call in the error path to properly disable
> the regulator.
> 
> Fixes: de34a4053250 ("hwmon: sy7636a: Add temperature driver for sy7636a")
> Signed-off-by: Haotian Zhang <vulab@...as.ac.cn>
> ---
>   drivers/hwmon/sy7636a-hwmon.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/hwmon/sy7636a-hwmon.c b/drivers/hwmon/sy7636a-hwmon.c
> index ed110884786b..b8e598a616ad 100644
> --- a/drivers/hwmon/sy7636a-hwmon.c
> +++ b/drivers/hwmon/sy7636a-hwmon.c
> @@ -88,6 +88,7 @@ static int sy7636a_sensor_probe(struct platform_device *pdev)
>   	if (IS_ERR(hwmon_dev)) {
>   		err = PTR_ERR(hwmon_dev);
>   		dev_err(&pdev->dev, "Unable to register hwmon device, returned %d\n", err);
> +		regulator_disable(regulator);

I would suggest to use devm_regulator_get_enable() instead of devm_regulator_get()
instead. That also solves the problem that regulator_disable() is not called when
the driver is removed.

Thanks,
Guenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ