[PATCH AUTOSEL 5.4 045/130] mmc: mediatek: fix mem leak in msdc_drv_probe

Sasha Levin
2020-12-23T02:20:35Z

From: Zheng Liang <zhengliang6@huawei.com>

[ Upstream commit bbba85fae44134e00c493705bd5604fd63958315 ]

It should use mmc_free_host to free mem in error patch of
msdc_drv_probe.

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zheng Liang <zhengliang6@huawei.com>
Reviewed-by: Chaotian Jing <chaotian.jing@mediatek.com>
Link: https://lore.kernel.org/r/20201112092530.32446-1-zhengliang6@huawei.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/mmc/host/mtk-sd.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 9d47a2bd2546b..3c11bd5a3b86c 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -2242,8 +2242,10 @@ static int msdc_drv_probe(struct platform_device *pdev)

host->reset = devm_reset_control_get_optional_exclusive(&pdev->dev,
"hrst");
- if (IS_ERR(host->reset))
- return PTR_ERR(host->reset);
+ if (IS_ERR(host->reset)) {
+ ret = PTR_ERR(host->reset);
+ goto host_free;
+ }

host->irq = platform_get_irq(pdev, 0);
if (host->irq < 0) {
--
2.27.0