hwmon: Relax name attribute validation for new APIs
Guenter Roeck
maintainerPATCH 1/1 hwmon: Relax name attribute validation for new APIs
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.
--- drivers/hwmon/hwmon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/hwmon/hwmon.c +3 -2
@@ -544,9 +544,10 @@ __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\n" , + name); id =ida_simple_get (&hwmon_ida,0 ,0 ,GFP_KERNEL );if (id <0 )
Signature · 1 line
2.7.4
Hi Guenter, Dmitry,
Quoted 25 lines · Guenter Roeck
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.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/hwmon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/hwmon/hwmon.c +0
-0
drivers/hwmon/hwmon.c __hwmon_device_register(struct device *dev, const char *name, void *drvdata, · line 550
Quoted 9 lines
drivers/hwmon/hwmon.c +3
-2@@ -544,9 +544,10 @@ __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\n" , + name);
May I suggest adding ", please fix"?
drivers/hwmon/hwmon.c __hwmon_device_register(struct device *dev, const char *name, void *drvdata, · line 553
Quoted 3 lines
drivers/hwmon/hwmon.c +0
-0id =ida_simple_get (&hwmon_ida,0 ,0 ,GFP_KERNEL );if (id <0 )
Do I understand correctly that in the long run we will make it a fatal error again?
Signature · 2 lines
Jean Delvare SUSE L3 Support
Guenter Roeck
maintainerQuoted 31 lines · Jean Delvare
Hi Guenter, Dmitry,
Quoted 28 lines · Guenter Roeck
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.
Signed-off-by Guenter Roeck <[email protected]>--- drivers/hwmon/hwmon.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/hwmon/hwmon.c +0
-0@@ -544,9 +544,10 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,struct device *hdev;int i, j, err, id;
Quoted 9 lines
drivers/hwmon/hwmon.c __hwmon_device_register(struct device *dev, const char *name, void *drvdata, · line 550
Quoted 6 lines
drivers/hwmon/hwmon.c +3
-2-/* 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\n" , + name);May I suggest adding ", please fix"?
Ok, will do.
Quoted 9 lines
drivers/hwmon/hwmon.c __hwmon_device_register(struct device *dev, const char *name, void *drvdata, · line 553
Quoted 3 lines
drivers/hwmon/hwmon.c +0
-0id =ida_simple_get (&hwmon_ida,0 ,0 ,GFP_KERNEL );if (id <0 )Reviewed-by Jean Delvare <[email protected]>Do I understand correctly that in the long run we will make it a fatal error again?
Hopefully, after there are no more drivers to convert, and after all converted drivers fixed the problem.
Thanks,
Guenter