From: Guenter Roeck <linux@roeck-us.net>
To: Ma Ke <make_ruc2021@163.com>,
jdelvare@suse.com, jic23@kernel.org, punitagrawal@gmail.com
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] hwmon: Check dev_set_name() return value
Date: Tue, 10 Dec 2024 20:42:36 -0800 [thread overview]
Message-ID: <861fc71e-45ca-405a-9b1e-849cbcb8fcaf@roeck-us.net> (raw)
In-Reply-To: <20241211023404.2174629-1-make_ruc2021@163.com>
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@vger.kernel.org
> Fixes: d560168b5d0f ("hwmon: (core) New hwmon registration API")
> Signed-off-by: Ma Ke <make_ruc2021@163.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
prev parent reply other threads:[~2024-12-11 4:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-11 2:34 Ma Ke
2024-12-11 4:42 ` Guenter Roeck [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=861fc71e-45ca-405a-9b1e-849cbcb8fcaf@roeck-us.net \
--to=linux@roeck-us.net \
--cc=jdelvare@suse.com \
--cc=jic23@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=make_ruc2021@163.com \
--cc=punitagrawal@gmail.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®