All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: lm-sensors@vger.kernel.org
Subject: Re: [lm-sensors] [PATCH] hwmon: Do not accept name attributes which include '-'
Date: Sun, 02 Mar 2014 16:29:11 +0000	[thread overview]
Message-ID: <53135C57.1000403@roeck-us.net> (raw)
In-Reply-To: <1393612837-20042-1-git-send-email-linux@roeck-us.net>

On 03/02/2014 08:24 AM, Guenter Roeck wrote:
> Hi Jean,
>
> On 03/02/2014 05:17 AM, Jean Delvare wrote:
>> Hi Guenter,
>>
>> On Fri, 28 Feb 2014 10:40:37 -0800, Guenter Roeck wrote:
>>> hwmon name attributes must not include '-', as specified in
>>> Documentation/hwmon/sysfs-interface. Validate the name attribute
>>> and return an error if it is invalid.
>>>
>>> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>>> ---
>>>   drivers/hwmon/hwmon.c |    5 +++++
>>>   1 file changed, 5 insertions(+)
>>>
>>> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
>>> index e176a43..6a84df4 100644
>>> --- a/drivers/hwmon/hwmon.c
>>> +++ b/drivers/hwmon/hwmon.c
>>> @@ -22,6 +22,7 @@
>>>   #include <linux/gfp.h>
>>>   #include <linux/spinlock.h>
>>>   #include <linux/pci.h>
>>> +#include <linux/string.h>
>>>
>>>   #define HWMON_ID_PREFIX "hwmon"
>>>   #define HWMON_ID_FORMAT HWMON_ID_PREFIX "%d"
>>> @@ -99,6 +100,10 @@ hwmon_device_register_with_groups(struct device *dev, const char *name,
>>>       struct hwmon_device *hwdev;
>>>       int err, id;
>>>
>>> +    /* Do not accept '-' in hwmon name attribute */
>>> +    if (name && strchr(name, '-'))
>>> +        return ERR_PTR(-EINVAL);
>>> +
>>
>> I like it, thanks for doing that. Maybe we could check for spaces too?
>> That would break libsensors as well, and I vaguely recalled that
>> someone attempted that once already (caught during code review,
>> thankfully.)
>>
>
> Makes sense. Any other invalid characters we should look out for
> since we are at it ?
>

Newline, '\', '?', '*' comes into mind, and possibly quotes (single
and double).

Guenter


_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

  parent reply	other threads:[~2014-03-02 16:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 18:40 [lm-sensors] [PATCH] hwmon: Do not accept name attributes which include '-' Guenter Roeck
2014-03-02 13:17 ` Jean Delvare
2014-03-02 13:54 ` Jean Delvare
2014-03-02 14:21 ` Jean Delvare
2014-03-02 16:24 ` Guenter Roeck
2014-03-02 16:29 ` Guenter Roeck [this message]
2014-03-02 20:59 ` Jean Delvare

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=53135C57.1000403@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=lm-sensors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.