All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Alexandru Ardelean <alexandru.ardelean@analog.com>
Cc: <linux-iio@vger.kernel.org>, Lars-Peter Clausen <lars@metafoo.de>
Subject: Re: [V2 PATCH] iio: Fix scan mask selection
Date: Wed, 20 Feb 2019 15:43:49 +0000	[thread overview]
Message-ID: <20190220154349.15a8c8cb@archlinux> (raw)
In-Reply-To: <20190220151132.10791-1-alexandru.ardelean@analog.com>

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

> From: Lars-Peter Clausen <lars@metafoo.de>
> 
> 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@metafoo.de>
> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
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) {


      reply	other threads:[~2019-02-20 15:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-20 15:11 [V2 PATCH] iio: Fix scan mask selection Alexandru Ardelean
2019-02-20 15:43 ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190220154349.15a8c8cb@archlinux \
    --to=jic23@kernel.org \
    --cc=alexandru.ardelean@analog.com \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.