Skip to content

Commit 1e73409

Browse files
Colin Ian Kinggregkh
authored andcommitted
mmc: moxart: Fix null pointer dereference on pointer host
commit 0eab756 upstream. There are several error return paths that dereference the null pointer host because the pointer has not yet been set to a valid value. Fix this by adding a new out_mmc label and exiting via this label to avoid the host clean up and hence the null pointer dereference. Addresses-Coverity: ("Explicit null dereference") Fixes: 8105c2a ("mmc: moxart: Fix reference count leaks in moxart_probe") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20211013100052.125461-1-colin.king@canonical.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 188bf40 commit 1e73409

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

drivers/mmc/host/moxart-mmc.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -569,37 +569,37 @@ static int moxart_probe(struct platform_device *pdev)
569569
if (!mmc) {
570570
dev_err(dev, "mmc_alloc_host failed\n");
571571
ret = -ENOMEM;
572-
goto out;
572+
goto out_mmc;
573573
}
574574

575575
ret = of_address_to_resource(node, 0, &res_mmc);
576576
if (ret) {
577577
dev_err(dev, "of_address_to_resource failed\n");
578-
goto out;
578+
goto out_mmc;
579579
}
580580

581581
irq = irq_of_parse_and_map(node, 0);
582582
if (irq <= 0) {
583583
dev_err(dev, "irq_of_parse_and_map failed\n");
584584
ret = -EINVAL;
585-
goto out;
585+
goto out_mmc;
586586
}
587587

588588
clk = devm_clk_get(dev, NULL);
589589
if (IS_ERR(clk)) {
590590
ret = PTR_ERR(clk);
591-
goto out;
591+
goto out_mmc;
592592
}
593593

594594
reg_mmc = devm_ioremap_resource(dev, &res_mmc);
595595
if (IS_ERR(reg_mmc)) {
596596
ret = PTR_ERR(reg_mmc);
597-
goto out;
597+
goto out_mmc;
598598
}
599599

600600
ret = mmc_of_parse(mmc);
601601
if (ret)
602-
goto out;
602+
goto out_mmc;
603603

604604
host = mmc_priv(mmc);
605605
host->mmc = mmc;
@@ -690,6 +690,7 @@ static int moxart_probe(struct platform_device *pdev)
690690
dma_release_channel(host->dma_chan_tx);
691691
if (!IS_ERR_OR_NULL(host->dma_chan_rx))
692692
dma_release_channel(host->dma_chan_rx);
693+
out_mmc:
693694
if (mmc)
694695
mmc_free_host(mmc);
695696
return ret;

0 commit comments

Comments
 (0)