From c7e9571e8735e5b36ec441e07499d10ca9f2aeba Mon Sep 17 00:00:00 2001 From: "Isaac J. Manjarres" Date: Mon, 6 Jan 2020 16:58:04 -0800 Subject: [PATCH] iommu/arm-smmu: Fix memory leak with respect to TBU data structures When the TBU devices unbind from the TBU driver, all of the resources acquired through the devm_* functions are released. However, the interconnect resources are not acquired through the devm_* APIs. Since the TBU driver does not have a remove() call to release the interconnect resources, this results in a memory leak. Fix this by adding a remove() call to release the interconnect resources on device and driver unbind. Change-Id: Iac6b5a6b1da7ff989ae36775b39c5fa61294270a Signed-off-by: Isaac J. Manjarres --- drivers/iommu/arm-smmu.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 08016ea62bee..e5cde40b687e 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -5594,12 +5594,21 @@ static int qsmmuv500_tbu_probe(struct platform_device *pdev) return 0; } +static int qsmmuv500_tbu_remove(struct platform_device *pdev) +{ + struct qsmmuv500_tbu_device *tbu = dev_get_drvdata(&pdev->dev); + + arm_smmu_exit_power_resources(tbu->pwr); + return 0; +} + static struct platform_driver qsmmuv500_tbu_driver = { .driver = { .name = "qsmmuv500-tbu", .of_match_table = of_match_ptr(qsmmuv500_tbu_of_match), }, .probe = qsmmuv500_tbu_probe, + .remove = qsmmuv500_tbu_remove, }; MODULE_DESCRIPTION("IOMMU API for ARM architected SMMU implementations");