Skip to content

Commit

Permalink
hwmon: Relax name attribute validation for new APIs
Browse files Browse the repository at this point in the history
While invalid name attributes are really not desirable and do mess up
libsensors, enforcing valid names has the detrimental effect of driving
users away from using the new hardware monitoring API, especially those
registering name attributes violating the ABI restrictions. Another
undesirable side effect is that this violation and the resulting error
may only be discovered some time after a conversion to the new API,
which in turn may trigger a revert of that conversion.

To solve the problem, relax validation and only issue a warning instead
of returning an error if a name attribute violating the ABI is provided.
This lets callers continue to provide invalid name attributes while
notifying them about it.

Many thanks are due to Dmitry Torokhov for the idea.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Jan 31, 2017
1 parent f172841 commit 74d3b64
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/hwmon/hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,11 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
struct device *hdev;
int i, j, err, id;

/* Do not accept invalid characters in hwmon name attribute */
/* Complain about invalid characters in hwmon name attribute */
if (name && (!strlen(name) || strpbrk(name, "-* \t\n")))
return ERR_PTR(-EINVAL);
dev_warn(dev,
"hwmon: '%s' is not a valid name attribute, please fix\n",
name);

id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL);
if (id < 0)
Expand Down

0 comments on commit 74d3b64

Please sign in to comment.