Re: [V2 PATCH] iio: Fix scan mask selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 20 Feb 2019 17:11:32 +0200
Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx> wrote:

> From: Lars-Peter Clausen <lars@xxxxxxxxxx>
> 
> Fixes commit 057ac1acdfc4 ("iio: Use kmalloc_array() in
> iio_scan_mask_set()").
> 
> 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.
> 
> Signed-off-by: Lars-Peter Clausen <lars@xxxxxxxxxx>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@xxxxxxxxxx>
Applied with a bit of tidying as the fixes tag should be down here.

I also added a note to observe that the fixes tag isn't entirely accurate
as the bug was there before that one, it's just that a different fix will
be necessary to backport further.

Added stable tag.

Thanks,

Jonathan

> ---
> 
> Changelog V1->V2:
> * added `Fixes commit 057ac1acdfc4 ("iio: Use kmalloc_array() in
>   iio_scan_mask_set()").` comment
> 
>  drivers/iio/industrialio-buffer.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index cd5bfe39591b..dadd921a4a30 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -320,9 +320,8 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
>  	const unsigned long *mask;
>  	unsigned long *trialmask;
>  
> -	trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
> -				  sizeof(*trialmask),
> -				  GFP_KERNEL);
> +	trialmask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
> +			    sizeof(*trialmask), GFP_KERNEL);
>  	if (trialmask == NULL)
>  		return -ENOMEM;
>  	if (!indio_dev->masklength) {




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux