diff options
author | Andreas Ruprecht | 2011-11-29 11:43:28 +0100 |
---|---|---|
committer | Greg Kroah-Hartman | 2011-11-30 11:37:33 +0100 |
commit | 6d3ff1cc99eb869af040e34c0bbe3035cc5c203b (patch) | |
tree | 8e0b64f62843d86abbf6cd93440d1ce081957afd /drivers | |
parent | staging: iio: Use kcalloc instead of kzalloc to allocate array (diff) | |
download | kernel-qcow2-linux-6d3ff1cc99eb869af040e34c0bbe3035cc5c203b.tar.gz kernel-qcow2-linux-6d3ff1cc99eb869af040e34c0bbe3035cc5c203b.tar.xz kernel-qcow2-linux-6d3ff1cc99eb869af040e34c0bbe3035cc5c203b.zip |
Staging: iio/adc: strict_strtoul was used with a long type variable
The function ad7280_store_balance_timer() parses data from a char*
buffer into a long variable, but uses the the function strict_strtoul
which expects a pointer to an unsigned long variable as its third
parameter.
As Dan Carpenter mentioned, the values are capped a few lines later,
but a check if val is negative is missing.
Now this function will return -ERANGE if there is a representation of
a negative number in buf.
Additionally the checkpatch.pl considers strict_strtoul as obsolete.
I replaced its call with the suggested kstrtoul.
Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/iio/adc/ad7280a.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c index f70bff247857..3fac9b1fc66c 100644 --- a/drivers/staging/iio/adc/ad7280a.c +++ b/drivers/staging/iio/adc/ad7280a.c @@ -456,10 +456,10 @@ static ssize_t ad7280_store_balance_timer(struct device *dev, struct iio_dev *indio_dev = dev_get_drvdata(dev); struct ad7280_state *st = iio_priv(indio_dev); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); - long val; + unsigned long val; int ret; - ret = strict_strtoul(buf, 10, &val); + ret = kstrtoul(buf, 10, &val); if (ret) return ret; |