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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1282269587.31048.3.camel@mola>
Date:	Fri, 20 Aug 2010 09:59:47 +0800
From:	Axel Lin <axel.lin@...il.com>
To:	linux-kernel <linux-kernel@...r.kernel.org>
Cc:	Mark Brown <broonie@...nsource.wolfsonmicro.com>,
	Liam Girdwood <lrg@...mlogic.co.uk>
Subject: [PATCH 2/4] regulator/wm831x-isink: fix potential NULL dereference

pdata is dereferenced earlier than tested for being NULL.
Thus move the dereference of "pdata" below the check for NULL.

Signed-off-by: Axel Lin <axel.lin@...il.com>
---
 drivers/regulator/wm831x-isink.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/regulator/wm831x-isink.c b/drivers/regulator/wm831x-isink.c
index 6c446cd..123d722 100644
--- a/drivers/regulator/wm831x-isink.c
+++ b/drivers/regulator/wm831x-isink.c
@@ -153,13 +153,16 @@ static __devinit int wm831x_isink_probe(struct platform_device *pdev)
 	struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
 	struct wm831x_pdata *pdata = wm831x->dev->platform_data;
 	struct wm831x_isink *isink;
-	int id = pdev->id % ARRAY_SIZE(pdata->isink);
 	struct resource *res;
-	int ret, irq;
+	int id, ret, irq;
 
+	if (pdata == NULL)
+		return -ENODEV;
+
+	id = pdev->id % ARRAY_SIZE(pdata->isink);
 	dev_dbg(&pdev->dev, "Probing ISINK%d\n", id + 1);
 
-	if (pdata == NULL || pdata->isink[id] == NULL)
+	if (pdata->isink[id] == NULL)
 		return -ENODEV;
 
 	isink = kzalloc(sizeof(struct wm831x_isink), GFP_KERNEL);
-- 
1.7.2



--
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