]> git.karo-electronics.de Git - linux-beck.git/commitdiff
mfd: asic3: Fix potential null pointer dereference
authorSachin Kamat <sachin.kamat@linaro.org>
Tue, 10 Jun 2014 10:00:34 +0000 (15:30 +0530)
committerLee Jones <lee.jones@linaro.org>
Wed, 9 Jul 2014 13:58:01 +0000 (14:58 +0100)
We previously assumed 'mem_sdio' could be null but it is
dereferenced in ioremap(). Add a check to avoid a potential
null pointer dereference error.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
drivers/mfd/asic3.c

index 9f6294f2a0708ab6be063d4bfbc0f98ad1062fa5..9fc4186d41328af729beb99cb30488a89b64d937 100644 (file)
@@ -899,13 +899,15 @@ static int __init asic3_mfd_probe(struct platform_device *pdev,
        ds1wm_resources[0].end   >>= asic->bus_shift;
 
        /* MMC */
-       asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) +
+       if (mem_sdio) {
+               asic->tmio_cnf = ioremap((ASIC3_SD_CONFIG_BASE >> asic->bus_shift) +
                                 mem_sdio->start,
                                 ASIC3_SD_CONFIG_SIZE >> asic->bus_shift);
-       if (!asic->tmio_cnf) {
-               ret = -ENOMEM;
-               dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n");
-               goto out;
+               if (!asic->tmio_cnf) {
+                       ret = -ENOMEM;
+                       dev_dbg(asic->dev, "Couldn't ioremap SD_CONFIG\n");
+                       goto out;
+               }
        }
        asic3_mmc_resources[0].start >>= asic->bus_shift;
        asic3_mmc_resources[0].end   >>= asic->bus_shift;