]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.37/iio-fix-scan-mask-selection.patch
Linux 4.19.37
[thirdparty/kernel/stable-queue.git] / releases / 4.19.37 / iio-fix-scan-mask-selection.patch
CommitLineData
85647c5c
GKH
1From 20ea39ef9f2f911bd01c69519e7d69cfec79fde3 Mon Sep 17 00:00:00 2001
2From: Lars-Peter Clausen <lars@metafoo.de>
3Date: Wed, 20 Feb 2019 17:11:32 +0200
4Subject: iio: Fix scan mask selection
5
6From: Lars-Peter Clausen <lars@metafoo.de>
7
8commit 20ea39ef9f2f911bd01c69519e7d69cfec79fde3 upstream.
9
10The trialmask is expected to have all bits set to 0 after allocation.
11Currently kmalloc_array() is used which does not zero the memory and so
12random bits are set. This results in random channels being enabled when
13they shouldn't. Replace kmalloc_array() with kcalloc() which has the same
14interface but zeros the memory.
15
16Note the fix is actually required earlier than the below fixes tag, but
17will require a manual backport due to move from kmalloc to kmalloc_array.
18
19Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
20Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
21Fixes commit 057ac1acdfc4 ("iio: Use kmalloc_array() in iio_scan_mask_set()").
22Cc: <Stable@vger.kernel.org>
23Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
24Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25
26---
27 drivers/iio/industrialio-buffer.c | 5 ++---
28 1 file changed, 2 insertions(+), 3 deletions(-)
29
30--- a/drivers/iio/industrialio-buffer.c
31+++ b/drivers/iio/industrialio-buffer.c
32@@ -320,9 +320,8 @@ static int iio_scan_mask_set(struct iio_
33 const unsigned long *mask;
34 unsigned long *trialmask;
35
36- trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
37- sizeof(*trialmask),
38- GFP_KERNEL);
39+ trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
40+ sizeof(*trialmask), GFP_KERNEL);
41 if (trialmask == NULL)
42 return -ENOMEM;
43 if (!indio_dev->masklength) {