Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-02-15 10:23:48 +0100
committerJiri Slaby <jslaby@suse.cz>2019-02-15 10:23:54 +0100
commitecf9746574a622badc4056f19d6f76f3d3b78ea0 (patch)
treeae04617cde88c69a03d15863b83f5e4a17d341fa
parent0a065bfb83e631776130cb824249c05c3138b415 (diff)
tools: iio: iio_generic_buffer: make num_loops signed
-rw-r--r--patches.kernel.org/4.20.9-006-tools-iio-iio_generic_buffer-make-num_loops-si.patch45
-rw-r--r--series.conf1
2 files changed, 46 insertions, 0 deletions
diff --git a/patches.kernel.org/4.20.9-006-tools-iio-iio_generic_buffer-make-num_loops-si.patch b/patches.kernel.org/4.20.9-006-tools-iio-iio_generic_buffer-make-num_loops-si.patch
new file mode 100644
index 0000000000..d50b595bde
--- /dev/null
+++ b/patches.kernel.org/4.20.9-006-tools-iio-iio_generic_buffer-make-num_loops-si.patch
@@ -0,0 +1,45 @@
+From: Martin Kelly <mkelly@xevo.com>
+Date: Fri, 11 Jan 2019 23:13:09 +0000
+Subject: [PATCH] tools: iio: iio_generic_buffer: make num_loops signed
+References: bnc#1012628
+Patch-mainline: 4.20.9
+Git-commit: b119d3bc328e7a9574861ebe0c2110e2776c2de1
+
+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>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+---
+ tools/iio/iio_generic_buffer.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+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;
+
+--
+2.20.1
+
diff --git a/series.conf b/series.conf
index 249f08d946..b4818feb88 100644
--- a/series.conf
+++ b/series.conf
@@ -1088,6 +1088,7 @@
patches.kernel.org/4.20.9-003-mtd-spinand-Fix-the-error-cleanup-path-in-spin.patch
patches.kernel.org/4.20.9-004-mtd-rawnand-gpmi-fix-MX28-bus-master-lockup-pr.patch
patches.kernel.org/4.20.9-005-libata-Add-NOLPM-quirk-for-SAMSUNG-MZ7TE512HMH.patch
+ patches.kernel.org/4.20.9-006-tools-iio-iio_generic_buffer-make-num_loops-si.patch
########################################################
# Build fixes that apply to the vanilla kernel too.