Skip to content

Commit cf3f15b

Browse files
harshimogalapallistorulf
authored andcommitted
mmc: sunplus: Fix error handling in spmmc_drv_probe()
When mmc allocation succeeds, the error paths are not freeing mmc. Fix the above issue by changing mmc_alloc_host() to devm_mmc_alloc_host() to simplify the error handling. Remove label 'probe_free_host' as devm_* api takes care of freeing, also remove mmc_free_host() from remove function as devm_* takes care of freeing. Fixes: 4e268fe ("mmc: Add mmc driver for Sunplus SP7021") Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Harshit Mogalapalli <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent dce6d8f commit cf3f15b

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

drivers/mmc/host/sunplus-mmc.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -863,11 +863,9 @@ static int spmmc_drv_probe(struct platform_device *pdev)
863863
struct spmmc_host *host;
864864
int ret = 0;
865865

866-
mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
867-
if (!mmc) {
868-
ret = -ENOMEM;
869-
goto probe_free_host;
870-
}
866+
mmc = devm_mmc_alloc_host(&pdev->dev, sizeof(struct spmmc_host));
867+
if (!mmc)
868+
return -ENOMEM;
871869

872870
host = mmc_priv(mmc);
873871
host->mmc = mmc;
@@ -938,11 +936,6 @@ static int spmmc_drv_probe(struct platform_device *pdev)
938936

939937
clk_disable:
940938
clk_disable_unprepare(host->clk);
941-
942-
probe_free_host:
943-
if (mmc)
944-
mmc_free_host(mmc);
945-
946939
return ret;
947940
}
948941

@@ -956,7 +949,6 @@ static int spmmc_drv_remove(struct platform_device *dev)
956949
pm_runtime_put_noidle(&dev->dev);
957950
pm_runtime_disable(&dev->dev);
958951
platform_set_drvdata(dev, NULL);
959-
mmc_free_host(host->mmc);
960952

961953
return 0;
962954
}

0 commit comments

Comments
 (0)