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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 19 Feb 2010 21:14:52 +0100
From:	Roel Kluin <roel.kluin@...il.com>
To:	Ben Dooks <ben-linux@...ff.org>, linux-i2c@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH] i2c: dereference of NULL if request_irq() failsin sh_mobile_i2c_hook_irqs()

In the last iteration k equals 0, so we call platform_get_resource() with
-1 as a third argument. Since platform_get_resource() uses an unsigned it
is converted to 0xffffffff. platform_get_resource() fails for every index
and returns NULL. A test is lacking and we dereference NULL.

Also the variable q was assigned but not used.

Signed-off-by: Roel Kluin <roel.kluin@...il.com>
---
 drivers/i2c/busses/i2c-sh_mobile.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index ccc4641..5871335 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -496,7 +496,7 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook)
 {
 	struct resource *res;
 	int ret = -ENXIO;
-	int q, m;
+	int m;
 	int k = 0;
 	int n = 0;
 
@@ -516,12 +516,16 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook)
 	ret = 0;
 
  rollback:
-	for (q = k; k >= 0; k--) {
-		for (m = n; m >= res->start; m--)
-			free_irq(m, dev);
+	for (m = n; m >= res->start; m--)
+		free_irq(m, dev);
 
+	while (k--) {
 		res = platform_get_resource(dev, IORESOURCE_IRQ, k - 1);
-		m = res->end;
+		if (res == NULL)
+			break;
+
+		for (m = res->end; m >= res->start; m--)
+			free_irq(m, dev);
 	}
 
 	return ret;
--
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