mmc: dw_mmc-pltfm: fix the potential NULL pointer dereference
authorJaehoon Chung <jh80.chung@samsung.com>
Fri, 21 Oct 2016 10:57:57 +0000 (19:57 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Nov 2016 15:36:35 +0000 (16:36 +0100)
commit 45c7a4908a307a023e237a64a3eadcafc4836493 upstream.

platform_get_resource can be returned the NULL pointer.
Then regs->start should be referred to NULL Pointer.
devm_ioremap_resource() checks whether res is NULL or not.

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/mmc/host/dw_mmc-pltfm.c

index 81bdeeb05a4d23426ecf39119a54d544eb8342f9..7dcfb1d5034fba36f02405807387a049ba37dd28 100644 (file)
@@ -59,12 +59,13 @@ int dw_mci_pltfm_register(struct platform_device *pdev,
        host->pdata = pdev->dev.platform_data;
 
        regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       /* Get registers' physical base address */
-       host->phy_regs = regs->start;
        host->regs = devm_ioremap_resource(&pdev->dev, regs);
        if (IS_ERR(host->regs))
                return PTR_ERR(host->regs);
 
+       /* Get registers' physical base address */
+       host->phy_regs = regs->start;
+
        platform_set_drvdata(pdev, host);
        return dw_mci_probe(host);
 }