From: Kari Argillander <kari.argillander@gmail.com>
To: Kari Argillander <kari.argillander@gmail.com>,
Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] hwmon: Fix wrong return errno in *sanitize_name()
Date: Fri, 19 Dec 2025 17:48:14 +0200 [thread overview]
Message-ID: <20251219-hwmon-fixes-v1-1-21b29097ea3b@gmail.com> (raw)
In-Reply-To: <20251219-hwmon-fixes-v1-0-21b29097ea3b@gmail.com>
Currently if user of *sanitize_name() function gives nullptr for name
they get's ENOMEM. Logically it should be EINVAL.
Signed-off-by: Kari Argillander <kari.argillander@gmail.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 0b4bdcd33c7b..7a784d685d77 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -1260,6 +1260,9 @@ static char *__hwmon_sanitize_name(struct device *dev, const char *old_name)
*/
char *hwmon_sanitize_name(const char *name)
{
+ if (!name)
+ return ERR_PTR(-EINVAL);
+
return __hwmon_sanitize_name(NULL, name);
}
EXPORT_SYMBOL_GPL(hwmon_sanitize_name);
@@ -1276,7 +1279,7 @@ EXPORT_SYMBOL_GPL(hwmon_sanitize_name);
*/
char *devm_hwmon_sanitize_name(struct device *dev, const char *name)
{
- if (!dev)
+ if (!dev || !name)
return ERR_PTR(-EINVAL);
return __hwmon_sanitize_name(dev, name);
--
2.43.0
next prev parent reply other threads:[~2025-12-19 15:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 15:48 [PATCH 0/2] hwmon: Minor errno and sysfs fixes Kari Argillander
2025-12-19 15:48 ` Kari Argillander [this message]
2025-12-19 16:46 ` [PATCH 1/2] hwmon: Fix wrong return errno in *sanitize_name() Guenter Roeck
2025-12-19 15:48 ` [PATCH 2/2] hwmon: Use sysfs_emit in show function callsbacks Kari Argillander
2025-12-19 16:47 ` 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=20251219-hwmon-fixes-v1-1-21b29097ea3b@gmail.com \
--to=kari.argillander@gmail.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/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®