linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Ardelean, Alexandru" <alexandru.Ardelean@analog.com>
To: "navid.emamdoost@gmail.com" <navid.emamdoost@gmail.com>
Cc: "Popa, Stefan Serban" <StefanSerban.Popa@analog.com>,
	"emamd001@umn.edu" <emamd001@umn.edu>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"jic23@kernel.org" <jic23@kernel.org>,
	"knaack.h@gmx.de" <knaack.h@gmx.de>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	"lars@metafoo.de" <lars@metafoo.de>,
	"smccaman@umn.edu" <smccaman@umn.edu>,
	"kjlu@umn.edu" <kjlu@umn.edu>,
	"pmeerw@pmeerw.net" <pmeerw@pmeerw.net>
Subject: Re: [PATCH] iio: imu: adis16400: fix memory leak
Date: Thu, 19 Sep 2019 06:52:36 +0000	[thread overview]
Message-ID: <76a7c8d43f8c03a0549d157bbf278b515cfbc047.camel@analog.com> (raw)
In-Reply-To: <20190918170306.4779-1-navid.emamdoost@gmail.com>

On Wed, 2019-09-18 at 12:03 -0500, Navid Emamdoost wrote:
> [External]
> 

Hey,

Thanks for this patch as well.
Comments inline here as well.

> In adis_update_scan_mode_burst, if adis->buffer allocation fails release
> the adis->xfer.
> 
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
>  drivers/iio/imu/adis_buffer.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/imu/adis_buffer.c
> b/drivers/iio/imu/adis_buffer.c
> index 9ac8356d9a95..1dbe25572a39 100644
> --- a/drivers/iio/imu/adis_buffer.c
> +++ b/drivers/iio/imu/adis_buffer.c
> @@ -35,8 +35,10 @@ static int adis_update_scan_mode_burst(struct iio_dev
> *indio_dev,
>  		return -ENOMEM;
>  
>  	adis->buffer = kzalloc(burst_length + sizeof(u16), GFP_KERNEL);
> -	if (!adis->buffer)
> +	if (!adis->buffer) {
> +		kfree(adis->xfer);

Same as the other patch: it would be a good idea to do "adis->xfer = NULL"
here.

>  		return -ENOMEM;
> +	}
>  
>  	tx = adis->buffer + burst_length;
>  	tx[0] = ADIS_READ_REG(adis->burst->reg_cmd);

  reply	other threads:[~2019-09-19  6:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 17:03 [PATCH] iio: imu: adis16400: fix memory leak Navid Emamdoost
2019-09-19  6:52 ` Ardelean, Alexandru [this message]
2019-09-19 15:56   ` [PATCH v2] " Navid Emamdoost
2019-09-20  6:46     ` Ardelean, Alexandru
2019-09-21 18:15       ` Jonathan Cameron

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=76a7c8d43f8c03a0549d157bbf278b515cfbc047.camel@analog.com \
    --to=alexandru.ardelean@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=StefanSerban.Popa@analog.com \
    --cc=emamd001@umn.edu \
    --cc=jic23@kernel.org \
    --cc=kjlu@umn.edu \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=navid.emamdoost@gmail.com \
    --cc=pmeerw@pmeerw.net \
    --cc=smccaman@umn.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).