]> Pileus Git - ~andy/linux/commitdiff
mfd: sta2x11: Fix potential NULL pointer dereference in __sta2x11_mfd_mask()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Sun, 2 Dec 2012 13:36:22 +0000 (08:36 -0500)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 2 Dec 2012 23:46:49 +0000 (00:46 +0100)
The dereference to 'mfd' should be moved below the NULL test.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/sta2x11-mfd.c

index 6fb0938a9665aba2d4a2974dc24e32c4b1d2c797..009b4b7721eb87ff13125c4205ae4fc476ef20c2 100644 (file)
@@ -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;