linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] mfd: pm8921: potential NULL dereference in pm8921_remove()
@ 2013-11-07  8:04 Dan Carpenter
  2013-11-07 10:06 ` Lee Jones
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2013-11-07  8:04 UTC (permalink / raw)
  To: David Brown, Abhijeet Dharmapurikar
  Cc: Daniel Walker, Bryan Huntsman, Samuel Ortiz, Lee Jones,
	linux-arm-msm, kernel-janitors

We assume that "pmic" could be NULL and then dereference it two lines
later.  I fix this by moving the dereference inside the NULL check.

Fixes: c013f0a56c56 ('mfd: Add pm8xxx irq support')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c
index a6841f7..484fe66 100644
--- a/drivers/mfd/pm8921-core.c
+++ b/drivers/mfd/pm8921-core.c
@@ -171,11 +171,12 @@ static int pm8921_remove(struct platform_device *pdev)
 	drvdata = platform_get_drvdata(pdev);
 	if (drvdata)
 		pmic = drvdata->pm_chip_data;
-	if (pmic)
+	if (pmic) {
 		mfd_remove_devices(pmic->dev);
-	if (pmic->irq_chip) {
-		pm8xxx_irq_exit(pmic->irq_chip);
-		pmic->irq_chip = NULL;
+		if (pmic->irq_chip) {
+			pm8xxx_irq_exit(pmic->irq_chip);
+			pmic->irq_chip = NULL;
+		}
 	}
 
 	return 0;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-11-08  8:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-07  8:04 [patch] mfd: pm8921: potential NULL dereference in pm8921_remove() Dan Carpenter
2013-11-07 10:06 ` Lee Jones
2013-11-07 10:50   ` Dan Carpenter
2013-11-07 11:22     ` Lee Jones
2013-11-08  8:48       ` Dan Carpenter

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