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] [day] [month] [year] [list]
Message-ID: <861fc71e-45ca-405a-9b1e-849cbcb8fcaf@roeck-us.net>
Date: Tue, 10 Dec 2024 20:42:36 -0800
From: Guenter Roeck <linux@...ck-us.net>
To: Ma Ke <make_ruc2021@....com>, jdelvare@...e.com, jic23@...nel.org,
 punitagrawal@...il.com
Cc: linux-hwmon@...r.kernel.org, linux-kernel@...r.kernel.org,
 stable@...r.kernel.org
Subject: Re: [PATCH] hwmon: Check dev_set_name() return value

On 12/10/24 18:34, Ma Ke wrote:
> It's possible that dev_set_name() returns -ENOMEM. We could catch and
> handle it by adding dev_set_name() return value check.
> 
> Cc: stable@...r.kernel.org
> Fixes: d560168b5d0f ("hwmon: (core) New hwmon registration API")
> Signed-off-by: Ma Ke <make_ruc2021@....com>
> ---
>   drivers/hwmon/hwmon.c | 5 ++++-
>   1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index bbb9cc44e29f..8b9bdb28650d 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -955,7 +955,10 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
>   	hdev->of_node = tdev ? tdev->of_node : NULL;
>   	hwdev->chip = chip;
>   	dev_set_drvdata(hdev, drvdata);
> -	dev_set_name(hdev, HWMON_ID_FORMAT, id);
> +	err = dev_set_name(hdev, HWMON_ID_FORMAT, id);
> +	if (err)
> +		goto free_hwmon;
> +
>   	err = device_register(hdev);
>   	if (err) {
>   		put_device(hdev);

As has been mentioned elsewhere:

If dev_set_name() fails, device_add() will fail. device_register() calls
device_add() and will therefore fail as well. For that reason, error
checking dev_set_name() is unnecessary for hwmon devices.

Guenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ