public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us•net>
To: Neelesh Gupta <neelegup@linux•vnet.ibm.com>,
	linuxppc-dev@lists•ozlabs.org, jdelvare@suse•de,
	lm-sensors@lm-sensors•org
Cc: sbhat@linux•vnet.ibm.com
Subject: Re: [PATCH v2] powerpc/powernv: hwmon driver for power values, fan rpm and temperature
Date: Wed, 18 Jun 2014 06:05:31 -0700	[thread overview]
Message-ID: <53A18E9B.7070306@roeck-us.net> (raw)
In-Reply-To: <53A1514F.30907@linux.vnet.ibm.com>

On 06/18/2014 01:43 AM, Neelesh Gupta wrote:
>
>>> +}
>>> +
>>> +static void __init get_sensor_index_attr(const char *name, u32 *index, char *attr)
>>> +{
>>> +    char *hash_pos = strchr(name, '#');
>>> +    char *dash_pos;
>>> +    u32 copy_len;
>>> +    char buf[8];
>>> +
>>> +    memset(buf, 0, sizeof(buf));
>>> +    *index = 0;
>>> +    *attr = '\0';
>>> +
>>> +    if (hash_pos) {
>>> +        dash_pos = strchr(hash_pos, '-');
>>> +        if (dash_pos) {
>>> +            copy_len = dash_pos - hash_pos - 1;
>>> +            if (copy_len < sizeof(buf)) {
>>> +                strncpy(buf, hash_pos + 1, copy_len);
>>> +                sscanf(buf, "%d", index);
>>
>> What if sscanf fails ? Might be an interesting exercise to try and create
>> multiple sensors with index 0 (or, for that matter, with the same index value).
>> Do you have any protection against bad input data ? Guess not; did you test
>> what happens if you pass bad data to the driver (such as duplicate sensor
>> entries) ?
>
> We can't have duplicate entries in the device tree under the same node ?
> But yes, rest other scenarios must be validated.
>

Was this a serious question ? Sorry, I wonder. It seems quite unlikely for a file
system to accept two files with the same name in the same directory.

Guenter

      reply	other threads:[~2014-06-18 13:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-19 14:26 [PATCH v2] powerpc/powernv: hwmon driver for power values, fan rpm and temperature Neelesh Gupta
2014-05-26  6:22 ` Neelesh Gupta
2014-05-26 14:12   ` Guenter Roeck
2014-05-28  7:23 ` Guenter Roeck
2014-05-28  7:41   ` Benjamin Herrenschmidt
2014-05-30 14:05     ` Neelesh Gupta
2014-06-09  8:15   ` Neelesh Gupta
2014-06-18  8:43   ` Neelesh Gupta
2014-06-18 13:05     ` Guenter Roeck [this message]

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=53A18E9B.7070306@roeck-us.net \
    --to=linux@roeck-us$(echo .)net \
    --cc=jdelvare@suse$(echo .)de \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=lm-sensors@lm-sensors$(echo .)org \
    --cc=neelegup@linux$(echo .)vnet.ibm.com \
    --cc=sbhat@linux$(echo .)vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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