diff mbox

mfd: pm8921: potential NULL dereference in pm8921_remove()

Message ID 20131107080420.GP21844@elgon.mountain (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Dan Carpenter Nov. 7, 2013, 8:04 a.m. UTC
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>

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Lee Jones Nov. 7, 2013, 10:06 a.m. UTC | #1
Just a thought. If you use `git format-patch` you don't have to
hand-craft the [PATCH] part of the subject line.

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

Patch applied thanks.
Dan Carpenter Nov. 7, 2013, 10:50 a.m. UTC | #2
On Thu, Nov 07, 2013 at 10:06:09AM +0000, Lee Jones wrote:
> Just a thought. If you use `git format-patch` you don't have to
> hand-craft the [PATCH] part of the subject line.

The lower case [patch] is annoying?

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Lee Jones Nov. 7, 2013, 11:22 a.m. UTC | #3
On Thu, 07 Nov 2013, Dan Carpenter wrote:

> On Thu, Nov 07, 2013 at 10:06:09AM +0000, Lee Jones wrote:
> > Just a thought. If you use `git format-patch` you don't have to
> > hand-craft the [PATCH] part of the subject line.
> 
> The lower case [patch] is annoying?

Not particularly. It didn't even make it to 'nit' status.

The pointer was more to aid you than anything. `git format-patch` is a
nice tool with some really useful options.
Dan Carpenter Nov. 8, 2013, 8:48 a.m. UTC | #4
On Thu, Nov 07, 2013 at 11:22:58AM +0000, Lee Jones wrote:
> On Thu, 07 Nov 2013, Dan Carpenter wrote:
> 
> > On Thu, Nov 07, 2013 at 10:06:09AM +0000, Lee Jones wrote:
> > > Just a thought. If you use `git format-patch` you don't have to
> > > hand-craft the [PATCH] part of the subject line.
> > 
> > The lower case [patch] is annoying?
> 
> Not particularly. It didn't even make it to 'nit' status.
> 
> The pointer was more to aid you than anything. `git format-patch` is a
> nice tool with some really useful options.

It would be hard for me to automate my work flow any more than it
currently is.  :P

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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;