From: Wei Yongjun Date: Sun, 2 Dec 2012 13:36:22 +0000 (-0500) Subject: mfd: sta2x11: Fix potential NULL pointer dereference in __sta2x11_mfd_mask() X-Git-Tag: upstream/snapshot3+hdmi~6042^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=709edecd4eaaa210ea9296c6d8ec5e9cedf1abe3;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git mfd: sta2x11: Fix potential NULL pointer dereference in __sta2x11_mfd_mask() The dereference to 'mfd' should be moved below the NULL test. Signed-off-by: Wei Yongjun Signed-off-by: Samuel Ortiz --- diff --git a/drivers/mfd/sta2x11-mfd.c b/drivers/mfd/sta2x11-mfd.c index 6fb0938..009b4b7 100644 --- a/drivers/mfd/sta2x11-mfd.c +++ b/drivers/mfd/sta2x11-mfd.c @@ -116,12 +116,14 @@ u32 __sta2x11_mfd_mask(struct pci_dev *pdev, u32 reg, u32 mask, u32 val, struct sta2x11_mfd *mfd = sta2x11_mfd_find(pdev); u32 r; unsigned long flags; - void __iomem *regs = mfd->regs[index]; + void __iomem *regs; if (!mfd) { dev_warn(&pdev->dev, ": can't access sctl regs\n"); return 0; } + + regs = mfd->regs[index]; if (!regs) { dev_warn(&pdev->dev, ": system ctl not initialized\n"); return 0;