]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: zynq_sdhci: fix uninitialized pointer deref on probe
authorMatwey V. Kornilov <matwey.kornilov@gmail.com>
Thu, 1 Aug 2019 15:00:05 +0000 (18:00 +0300)
committerPeng Fan <peng.fan@nxp.com>
Fri, 9 Aug 2019 05:45:25 +0000 (13:45 +0800)
Since commit 3d296365e4e8 ("mmc: sdhci: Add support for
sdhci-caps-mask") sdhci_setup_cfg() expects a valid sdhci_host mmc
field. Move the mmc field initialization before sdhci_setup_cfg()
call to avoid crash on mmc pointer dereference.

[this patch is based on commit 41a9fab8dac8 ("mmc: mv_sdhci: fix
uninitialized pointer deref on probe") by Baruch Siach]

Fixes: 3d296365e4e8 ("mmc: sdhci: Add support for sdhci-caps-mask")
Cc: Faiz Abbas <faiz_abbas@ti.com>
Cc: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Matwey V. Kornilov <matwey.kornilov@gmail.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Tested-by: Michal Simek <michal.simek@xilinx.com> (on zcu102/zc706)
drivers/mmc/zynq_sdhci.c

index c525084250c6ca2669e192d1bf7c2fd76349b4bc..3225a7ac93858460fcb4ace8ed5f912df27e99e0 100644 (file)
@@ -242,13 +242,14 @@ static int arasan_sdhci_probe(struct udevice *dev)
 
        host->max_clk = clock;
 
+       host->mmc = &plat->mmc;
+       host->mmc->dev = dev;
+       host->mmc->priv = host;
+
        ret = sdhci_setup_cfg(&plat->cfg, host, plat->f_max,
                              CONFIG_ZYNQ_SDHCI_MIN_FREQ);
-       host->mmc = &plat->mmc;
        if (ret)
                return ret;
-       host->mmc->priv = host;
-       host->mmc->dev = dev;
        upriv->mmc = host->mmc;
 
        return sdhci_probe(dev);