Skip to content

Commit 20ea39e

Browse files
larsclausenJonathan Cameron
authored andcommitted
iio: Fix scan mask selection
The trialmask is expected to have all bits set to 0 after allocation. Currently kmalloc_array() is used which does not zero the memory and so random bits are set. This results in random channels being enabled when they shouldn't. Replace kmalloc_array() with kcalloc() which has the same interface but zeros the memory. Note the fix is actually required earlier than the below fixes tag, but will require a manual backport due to move from kmalloc to kmalloc_array. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Fixes commit 057ac1a ("iio: Use kmalloc_array() in iio_scan_mask_set()"). Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 7ce0f21 commit 20ea39e

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎drivers/iio/industrialio-buffer.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,8 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
320320
const unsigned long *mask;
321321
unsigned long *trialmask;
322322

323-
trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
324-
sizeof(*trialmask),
325-
GFP_KERNEL);
323+
trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
324+
sizeof(*trialmask), GFP_KERNEL);
326325
if (trialmask == NULL)
327326
return -ENOMEM;
328327
if (!indio_dev->masklength) {

0 commit comments

Comments
 (0)