From: Jonathan Cameron <jic23@kernel.org>
To: Jesper Juhl <jj@chaosbits.net>
Cc: linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Michael Hennerich <michael.hennerich@analog.com>,
Greg Kroah-Hartman <gregkh@suse.de>,
Jonathan Cameron <jic23@cam.ac.uk>
Subject: Re: [PATCH] [staging] iio, adc: Do not leak memory in ad7280_event_handler()
Date: Sun, 06 Nov 2011 21:49:52 +0000 [thread overview]
Message-ID: <4EB70100.8030703@kernel.org> (raw)
In-Reply-To: <alpine.LNX.2.00.1111062246580.5763@swampdragon.chaosbits.net>
On 11/06/2011 09:49 PM, Jesper Juhl wrote:
> If ad7280_read_all_channels() returns <0 then we'll leak the memory
> allocated to 'channels' when we return and that variable goes out of
> scope.
> This patch fixes the leak.
>
Looks right to me - good spot. Only choice is whether a single exit
point makes sense rather than undwinding it here? Michael?
I'm happy with either solution, hence the ack.
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>
> ---
> drivers/staging/iio/adc/ad7280a.c | 4 +++-
> 1 files changed, 3 insertions(+), 1 deletions(-)
>
> note: I don't have the hardware, so patch is compile tested only.
>
> diff --git a/drivers/staging/iio/adc/ad7280a.c b/drivers/staging/iio/adc/ad7280a.c
> index 372d059..dddc03c 100644
> --- a/drivers/staging/iio/adc/ad7280a.c
> +++ b/drivers/staging/iio/adc/ad7280a.c
> @@ -687,8 +687,10 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
> return IRQ_HANDLED;
>
> ret = ad7280_read_all_channels(st, st->scan_cnt, channels);
> - if (ret < 0)
> + if (ret < 0) {
> + kfree(channels);
> return IRQ_HANDLED;
> + }
>
> for (i = 0; i < st->scan_cnt; i++) {
> if (((channels[i] >> 23) & 0xF) <= AD7280A_CELL_VOLTAGE_6) {
next prev parent reply other threads:[~2011-11-06 21:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-06 21:49 [PATCH] [staging] iio, adc: Do not leak memory in ad7280_event_handler() Jesper Juhl
2011-11-06 21:49 ` Jonathan Cameron [this message]
2011-11-07 7:37 ` Lars-Peter Clausen
2011-11-27 0:43 ` Greg KH
2011-12-05 22:48 ` Jesper Juhl
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=4EB70100.8030703@kernel.org \
--to=jic23@kernel.org \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=jic23@cam.ac.uk \
--cc=jj@chaosbits.net \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=paul.gortmaker@windriver.com \
/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