From: Dan Carpenter Date: Thu, 7 Nov 2013 08:04:20 +0000 (+0300) Subject: mfd: pm8921: Potential NULL dereference in pm8921_remove() X-Git-Tag: v3.10.106~116 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dad5635c15055b22304f11423442522dd8c086c4;p=thirdparty%2Fkernel%2Fstable.git mfd: pm8921: Potential NULL dereference in pm8921_remove() commit d6daef95127e41233ac8e2d8472d8c0cd8687d38 upstream. 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 Signed-off-by: Lee Jones Signed-off-by: Jiri Slaby Signed-off-by: Willy Tarreau --- diff --git a/drivers/mfd/pm8921-core.c b/drivers/mfd/pm8921-core.c index ecc137ffa8c3c..a28f434147fed 100644 --- a/drivers/mfd/pm8921-core.c +++ b/drivers/mfd/pm8921-core.c @@ -173,11 +173,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; + } } platform_set_drvdata(pdev, NULL); kfree(pmic);