diff mbox series

[-next,v2,1/2] ARM: imx: add missing iounmap()

Message ID 20210615125239.1348845-2-yangyingliang@huawei.com (mailing list archive)
State New, archived
Headers show
Series ARM: imx: free resources | expand

Commit Message

Yang Yingliang June 15, 2021, 12:52 p.m. UTC
Commit e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver")
introduced imx_mmdc_remove(), the mmdc_base need be unmapped in it if
config PERF_EVENTS is enabled.

If imx_mmdc_perf_init() fails, the mmdc_base also need be unmapped.

Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 arch/arm/mach-imx/mmdc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Aisheng Dong June 17, 2021, 12:20 p.m. UTC | #1
> From: Yang Yingliang <yangyingliang@huawei.com>
> Sent: Tuesday, June 15, 2021 8:53 PM
> Subject: [PATCH -next v2 1/2] ARM: imx: add missing iounmap()
> 
> Commit e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver")
> introduced imx_mmdc_remove(), the mmdc_base need be unmapped in it if
> config PERF_EVENTS is enabled.
> 
> If imx_mmdc_perf_init() fails, the mmdc_base also need be unmapped.
> 
> Fixes: e76bdfd7403a ("ARM: imx: Added perf functionality to mmdc driver")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>

Reviewed-by: Dong Aisheng <aisheng.dong@nxp.com>

Regards
Aisheng
diff mbox series

Patch

diff --git a/arch/arm/mach-imx/mmdc.c b/arch/arm/mach-imx/mmdc.c
index 0dfd0ae7a63d..8e57691aafe2 100644
--- a/arch/arm/mach-imx/mmdc.c
+++ b/arch/arm/mach-imx/mmdc.c
@@ -462,6 +462,7 @@  static int imx_mmdc_remove(struct platform_device *pdev)
 
 	cpuhp_state_remove_instance_nocalls(cpuhp_mmdc_state, &pmu_mmdc->node);
 	perf_pmu_unregister(&pmu_mmdc->pmu);
+	iounmap(pmu_mmdc->mmdc_base);
 	kfree(pmu_mmdc);
 	return 0;
 }
@@ -567,7 +568,11 @@  static int imx_mmdc_probe(struct platform_device *pdev)
 	val &= ~(1 << BP_MMDC_MAPSR_PSD);
 	writel_relaxed(val, reg);
 
-	return imx_mmdc_perf_init(pdev, mmdc_base);
+	err = imx_mmdc_perf_init(pdev, mmdc_base);
+	if (err)
+		iounmap(mmdc_base);
+
+	return err;
 }
 
 int imx_mmdc_get_ddr_type(void)