[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241211023404.2174629-1-make_ruc2021@163.com>
Date: Wed, 11 Dec 2024 10:34:04 +0800
From: Ma Ke <make_ruc2021@....com>
To: jdelvare@...e.com,
linux@...ck-us.net,
jic23@...nel.org,
punitagrawal@...il.com
Cc: linux-hwmon@...r.kernel.org,
linux-kernel@...r.kernel.org,
Ma Ke <make_ruc2021@....com>,
stable@...r.kernel.org
Subject: [PATCH] hwmon: Check dev_set_name() return value
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);
--
2.25.1
Powered by blists - more mailing lists