All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/fsl: Unwind pamu_domain_init if registration fails
@ 2026-11-26  9:49 Wanhui Fu
  2026-11-30  9:58 ` Jörg Rödel
  0 siblings, 1 reply; 2+ messages in thread
From: Wanhui Fu @ 2026-11-26  9:49 UTC (permalink / raw)
  To: joro, will, robin.murphy, timur, alex, Varun.Sethi; +Cc: iommu, Wanhui Fu

In fsl_pamu_init(), if platform_device_add() fails, the resources
allocated by pamu_domain_init() are not released. Add a helper
pamu_domain_exit() to do the cleanup and call it if platform_device_add()
fails.

Fixes: 695093e38c3e ("iommu/fsl: Freescale PAMU driver and iommu implementation.")
Signed-off-by: Wanhui Fu <fuwh1120@163.com>
---
 drivers/iommu/fsl_pamu.c        | 5 ++++-
 drivers/iommu/fsl_pamu.h        | 1 +
 drivers/iommu/fsl_pamu_domain.c | 8 ++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c
index c83bbc3faad5..55c666efe8ff 100644
--- a/drivers/iommu/fsl_pamu.c
+++ b/drivers/iommu/fsl_pamu.c
@@ -979,7 +979,7 @@ static __init int fsl_pamu_init(void)
 
 	ret = pamu_domain_init();
 	if (ret)
-		goto error_device_add;
+		goto error_domain_init;
 
 	ret = platform_device_add(pdev);
 	if (ret) {
@@ -990,6 +990,9 @@ static __init int fsl_pamu_init(void)
 	return 0;
 
 error_device_add:
+	pamu_domain_exit();
+
+error_domain_init:
 	platform_device_put(pdev);
 
 error_device_alloc:
diff --git a/drivers/iommu/fsl_pamu.h b/drivers/iommu/fsl_pamu.h
index 36df7975ff64..5c430d33e955 100644
--- a/drivers/iommu/fsl_pamu.h
+++ b/drivers/iommu/fsl_pamu.h
@@ -381,6 +381,7 @@ struct ome {
 
 /* Function prototypes */
 int pamu_domain_init(void);
+void pamu_domain_exit(void);
 int pamu_enable_liodn(int liodn);
 int pamu_disable_liodn(int liodn);
 int pamu_config_ppaace(int liodn, u32 omi, uint32_t stashid, int prot);
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 9664ef9840d2..498c29a255a0 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -460,3 +460,11 @@ int __init pamu_domain_init(void)
 
 	return ret;
 }
+
+void pamu_domain_exit(void)
+{
+	iommu_device_unregister(&pamu_iommu);
+	iommu_device_sysfs_remove(&pamu_iommu);
+	kmem_cache_destroy(iommu_devinfo_cache);
+	kmem_cache_destroy(fsl_pamu_domain_cache);
+}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-30  9:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  9:49 [PATCH] iommu/fsl: Unwind pamu_domain_init if registration fails Wanhui Fu
2026-11-30  9:58 ` Jörg Rödel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.