From: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
To: Guenter Roeck <linux@roeck-us.net>,
linuxppc-dev@lists.ozlabs.org, jdelvare@suse.de,
lm-sensors@lm-sensors.org
Cc: sbhat@linux.vnet.ibm.com
Subject: Re: [lm-sensors] [PATCH v2] powerpc/powernv: hwmon driver for power values, fan rpm and temperature
Date: Wed, 18 Jun 2014 08:55:59 +0000 [thread overview]
Message-ID: <53A1514F.30907@linux.vnet.ibm.com> (raw)
In-Reply-To: <53858F02.2020808@roeck-us.net>
>> +}
>> +
>> +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.
- Neelesh
>
>> + }
>> +
>> + strncpy(attr, dash_pos + 1, MAX_ATTR_LEN);
>> + }
>> + }
>> +}
>> +
>> +
>>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: Neelesh Gupta <neelegup@linux.vnet.ibm.com>
To: Guenter Roeck <linux@roeck-us.net>,
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 14:13:59 +0530 [thread overview]
Message-ID: <53A1514F.30907@linux.vnet.ibm.com> (raw)
In-Reply-To: <53858F02.2020808@roeck-us.net>
>> +}
>> +
>> +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.
- Neelesh
>
>> + }
>> +
>> + strncpy(attr, dash_pos + 1, MAX_ATTR_LEN);
>> + }
>> + }
>> +}
>> +
>> +
>>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
next prev parent reply other threads:[~2014-06-18 8:55 UTC|newest]
Thread overview: 18+ 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-19 14:38 ` [lm-sensors] " Neelesh Gupta
2014-05-26 6:22 ` Neelesh Gupta
2014-05-26 6:34 ` [lm-sensors] " Neelesh Gupta
2014-05-26 14:12 ` Guenter Roeck
2014-05-26 14:12 ` Guenter Roeck
2014-05-28 7:23 ` [lm-sensors] " Guenter Roeck
2014-05-28 7:23 ` Guenter Roeck
2014-05-28 7:41 ` [lm-sensors] " Benjamin Herrenschmidt
2014-05-28 7:41 ` Benjamin Herrenschmidt
2014-05-30 14:05 ` Neelesh Gupta
2014-05-30 14:17 ` [lm-sensors] " Neelesh Gupta
2014-06-09 8:15 ` Neelesh Gupta
2014-06-09 8:27 ` [lm-sensors] " Neelesh Gupta
2014-06-18 8:43 ` Neelesh Gupta [this message]
2014-06-18 8:55 ` Neelesh Gupta
2014-06-18 13:05 ` Guenter Roeck
2014-06-18 13:05 ` 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=53A1514F.30907@linux.vnet.ibm.com \
--to=neelegup@linux.vnet.ibm.com \
--cc=jdelvare@suse.de \
--cc=linux@roeck-us.net \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=lm-sensors@lm-sensors.org \
--cc=sbhat@linux.vnet.ibm.com \
/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.