From 5ac36d9c9691d552fbd639271fbc24fa92ebe3ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20L=C3=BCtke-Stetzkamp?= Date: Wed, 4 Apr 2018 22:15:33 +0200 Subject: [PATCH] staging: mt7621-mmc: Fix memory leek in case of error in probe MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If the base address is not successfully obtained in the probe function, then the mmc_host struct is not freed. Adding an exit for that case fixes the bug. Signed-off-by: Christian Lütke-Stetzkamp Reviewed-by: NeilBrown Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-mmc/sd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 5f829f79bfff9..065d1b34c2587 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -2719,8 +2719,10 @@ static int msdc_drv_probe(struct platform_device *pdev) //BUG_ON((!hw) || (!mem) || (irq < 0)); /* --- by chhung */ base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + if (IS_ERR(base)) { + ret = PTR_ERR(base); + goto host_free; + } /* Set host parameters to mmc */ mmc->ops = &mt_msdc_ops; @@ -2861,6 +2863,7 @@ release: if (mem) release_mem_region(mem->start, mem->end - mem->start + 1); +host_free: mmc_free_host(mmc); return ret; -- 2.30.2