lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1111062246580.5763@swampdragon.chaosbits.net>
Date:	Sun, 6 Nov 2011 22:49:22 +0100 (CET)
From:	Jesper Juhl <jj@...osbits.net>
To:	linux-iio@...r.kernel.org, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org
cc:	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Michael Hennerich <michael.hennerich@...log.com>,
	Greg Kroah-Hartman <gregkh@...e.de>,
	Jonathan Cameron <jic23@....ac.uk>
Subject: [PATCH] [staging] iio, adc: Do not leak memory in
 ad7280_event_handler()

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.

Signed-off-by: Jesper Juhl <jj@...osbits.net>
---
 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) {
-- 
1.7.7.2


-- 
Jesper Juhl <jj@...osbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ