]>
Commit | Line | Data |
---|---|---|
85647c5c GKH |
1 | From 20ea39ef9f2f911bd01c69519e7d69cfec79fde3 Mon Sep 17 00:00:00 2001 |
2 | From: Lars-Peter Clausen <lars@metafoo.de> | |
3 | Date: Wed, 20 Feb 2019 17:11:32 +0200 | |
4 | Subject: iio: Fix scan mask selection | |
5 | ||
6 | From: Lars-Peter Clausen <lars@metafoo.de> | |
7 | ||
8 | commit 20ea39ef9f2f911bd01c69519e7d69cfec79fde3 upstream. | |
9 | ||
10 | The trialmask is expected to have all bits set to 0 after allocation. | |
11 | Currently kmalloc_array() is used which does not zero the memory and so | |
12 | random bits are set. This results in random channels being enabled when | |
13 | they shouldn't. Replace kmalloc_array() with kcalloc() which has the same | |
14 | interface but zeros the memory. | |
15 | ||
16 | Note the fix is actually required earlier than the below fixes tag, but | |
17 | will require a manual backport due to move from kmalloc to kmalloc_array. | |
18 | ||
19 | Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> | |
20 | Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> | |
21 | Fixes commit 057ac1acdfc4 ("iio: Use kmalloc_array() in iio_scan_mask_set()"). | |
22 | Cc: <Stable@vger.kernel.org> | |
23 | Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> | |
24 | Signed-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) { |