mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ma Ke <make_ruc2021@163.com>
To: jdelvare@suse.com, linux@roeck-us.net, jic23@kernel.org,
	punitagrawal@gmail.com
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ma Ke <make_ruc2021@163.com>,
	stable@vger.kernel.org
Subject: [PATCH] hwmon: Check dev_set_name() return value
Date: Wed, 11 Dec 2024 10:34:04 +0800	[thread overview]
Message-ID: <20241211023404.2174629-1-make_ruc2021@163.com> (raw)

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);
-- 
2.25.1


             reply	other threads:[~2024-12-11  2:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-11  2:34 Ma Ke [this message]
2024-12-11  4:42 ` Guenter Roeck

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=20241211023404.2174629-1-make_ruc2021@163.com \
    --to=make_ruc2021@163.com \
    --cc=jdelvare@suse.com \
    --cc=jic23@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --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®