summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMartin Kelly <mkelly@xevo.com>2019-01-11 23:13:09 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-15 08:10:10 +0100
commit5b9ebf5bdf0a0baab1150cdcc011f00457a62319 (patch)
tree36d9e209485ddaa614dc4a9d679565cf046025f3 /tools
parent88ff6a0b99759d436cdb5bc5fd7b8afcafb57623 (diff)
tools: iio: iio_generic_buffer: make num_loops signed
commit b119d3bc328e7a9574861ebe0c2110e2776c2de1 upstream. Currently, num_loops is unsigned, but it's set by strtoll, which returns a (signed) long long int. This could lead to overflow, and it also makes the check "num_loops < 0" always be false, since num_loops is unsigned. Setting num_loops to -1 to loop forever is almost working because num_loops is getting set to a very high number, but it's technically still incorrect. Fix this issue by making num_loops signed. This also fixes an error found by Smatch. Signed-off-by: Martin Kelly <mkelly@xevo.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Fixes: 55dda0abcf9d ("tools: iio: iio_generic_buffer: allow continuous looping") Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/iio/iio_generic_buffer.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/iio/iio_generic_buffer.c b/tools/iio/iio_generic_buffer.c
index 3040830d7797..84545666a09c 100644
--- a/tools/iio/iio_generic_buffer.c
+++ b/tools/iio/iio_generic_buffer.c
@@ -330,7 +330,7 @@ static const struct option longopts[] = {
int main(int argc, char **argv)
{
- unsigned long long num_loops = 2;
+ long long num_loops = 2;
unsigned long timedelay = 1000000;
unsigned long buf_len = 128;