Skip to content

Commit 0eab756

Browse files
Colin Ian KingUlf Hansson
authored andcommitted
mmc: moxart: Fix null pointer dereference on pointer host
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>
1 parent 92d2321 commit 0eab756

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
@@ -566,37 +566,37 @@ static int moxart_probe(struct platform_device *pdev)
566566
if (!mmc) {
567567
dev_err(dev, "mmc_alloc_host failed\n");
568568
ret = -ENOMEM;
569-
goto out;
569+
goto out_mmc;
570570
}
571571

572572
ret = of_address_to_resource(node, 0, &res_mmc);
573573
if (ret) {
574574
dev_err(dev, "of_address_to_resource failed\n");
575-
goto out;
575+
goto out_mmc;
576576
}
577577

578578
irq = irq_of_parse_and_map(node, 0);
579579
if (irq <= 0) {
580580
dev_err(dev, "irq_of_parse_and_map failed\n");
581581
ret = -EINVAL;
582-
goto out;
582+
goto out_mmc;
583583
}
584584

585585
clk = devm_clk_get(dev, NULL);
586586
if (IS_ERR(clk)) {
587587
ret = PTR_ERR(clk);
588-
goto out;
588+
goto out_mmc;
589589
}
590590

591591
reg_mmc = devm_ioremap_resource(dev, &res_mmc);
592592
if (IS_ERR(reg_mmc)) {
593593
ret = PTR_ERR(reg_mmc);
594-
goto out;
594+
goto out_mmc;
595595
}
596596

597597
ret = mmc_of_parse(mmc);
598598
if (ret)
599-
goto out;
599+
goto out_mmc;
600600

601601
host = mmc_priv(mmc);
602602
host->mmc = mmc;
@@ -687,6 +687,7 @@ static int moxart_probe(struct platform_device *pdev)
687687
dma_release_channel(host->dma_chan_tx);
688688
if (!IS_ERR_OR_NULL(host->dma_chan_rx))
689689
dma_release_channel(host->dma_chan_rx);
690+
out_mmc:
690691
if (mmc)
691692
mmc_free_host(mmc);
692693
return ret;

0 commit comments

Comments
 (0)