summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-10-22 12:15:00 +0100
committerJonathan Cameron <jic23@kernel.org>2012-11-02 09:43:48 +0000
commit02330acda7ef88865e62e2763df2cdd735607cb4 (patch)
tree7ecf6e71011b4eb8578a1f56f40987dd74e0f12d
parent8f1b7eb11422d28fbc7432f0dee2f97aead09417 (diff)
downloadop-kernel-dev-02330acda7ef88865e62e2763df2cdd735607cb4.zip
op-kernel-dev-02330acda7ef88865e62e2763df2cdd735607cb4.tar.gz
iio: Reject trailing garbage when parsing fixed point numbers
When parsing a fixed point number IIO stops parsing the string once it has reached the last requested decimal place. This means that the remainder of the string is silently accepted regardless, of whether it is part of a valid number or not. This patch modifies the code to scan the whole string and only accept valid numbers. Since fract_mult is 0 after the last decimal place any digit that may follows won't affect the result. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r--drivers/iio/industrialio-core.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 0994239..7bb570b 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -445,8 +445,6 @@ static ssize_t iio_write_channel_info(struct device *dev,
integer = integer*10 + *buf - '0';
else {
fract += fract_mult*(*buf - '0');
- if (fract_mult == 1)
- break;
fract_mult /= 10;
}
} else if (*buf == '\n') {
OpenPOWER on IntegriCloud