All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/pamu: Free slab caches in pamu_domain_init()
@ 2026-11-26  8:59 Wanhui Fu
  2026-11-30  9:49 ` Jörg Rödel
  0 siblings, 1 reply; 4+ messages in thread
From: Wanhui Fu @ 2026-11-26  8:59 UTC (permalink / raw)
  To: joro, will, robin.murphy, jroedel; +Cc: iommu, Wanhui Fu

iommu_init_mempool() allocates two slab caches. Destroy both
caches on later error paths to avoid leaking resources when
initialization fails.

Fixes: 3ff2dcc05894 ("iommu/pamu: Fix PAMU boot crash")
Signed-off-by: Wanhui Fu <fuwh1120@163.com>
---
 drivers/iommu/fsl_pamu_domain.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 9664ef9840d2..683bf005a3a2 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -449,12 +449,17 @@ int __init pamu_domain_init(void)
 		return ret;
 
 	ret = iommu_device_sysfs_add(&pamu_iommu, NULL, NULL, "iommu0");
-	if (ret)
+	if (ret) {
+		kmem_cache_destroy(iommu_devinfo_cache);
+		kmem_cache_destroy(fsl_pamu_domain_cache);
 		return ret;
+	}
 
 	ret = iommu_device_register(&pamu_iommu, &fsl_pamu_ops, NULL);
 	if (ret) {
 		iommu_device_sysfs_remove(&pamu_iommu);
+		kmem_cache_destroy(iommu_devinfo_cache);
+		kmem_cache_destroy(fsl_pamu_domain_cache);
 		pr_err("Can't register iommu device\n");
 	}
 
-- 
2.25.1


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

* Re: [PATCH] iommu/pamu: Free slab caches in pamu_domain_init()
  2026-11-26  8:59 [PATCH] iommu/pamu: Free slab caches in pamu_domain_init() Wanhui Fu
@ 2026-11-30  9:49 ` Jörg Rödel
  2026-11-30 14:43   ` fuwh1120
  0 siblings, 1 reply; 4+ messages in thread
From: Jörg Rödel @ 2026-11-30  9:49 UTC (permalink / raw)
  To: Wanhui Fu; +Cc: will, robin.murphy, jroedel, iommu

On Thu, Nov 26, 2026 at 04:59:26PM +0800, Wanhui Fu wrote:
> iommu_init_mempool() allocates two slab caches. Destroy both
> caches on later error paths to avoid leaking resources when
> initialization fails.
> 
> Fixes: 3ff2dcc05894 ("iommu/pamu: Fix PAMU boot crash")
> Signed-off-by: Wanhui Fu <fuwh1120@163.com>

Applied, thanks. Please consider my inline comment for a follow-on patch.

> ---
>  drivers/iommu/fsl_pamu_domain.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
> index 9664ef9840d2..683bf005a3a2 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -449,12 +449,17 @@ int __init pamu_domain_init(void)
>  		return ret;
>  
>  	ret = iommu_device_sysfs_add(&pamu_iommu, NULL, NULL, "iommu0");
> -	if (ret)
> +	if (ret) {
> +		kmem_cache_destroy(iommu_devinfo_cache);
> +		kmem_cache_destroy(fsl_pamu_domain_cache);
>  		return ret;
> +	}
>  
>  	ret = iommu_device_register(&pamu_iommu, &fsl_pamu_ops, NULL);
>  	if (ret) {
>  		iommu_device_sysfs_remove(&pamu_iommu);
> +		kmem_cache_destroy(iommu_devinfo_cache);
> +		kmem_cache_destroy(fsl_pamu_domain_cache);
>  		pr_err("Can't register iommu device\n");
>  	}

This looks like it deserves a common failure path to get rid of the
duplication.

-Joerg

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

* Re: [PATCH] iommu/pamu: Free slab caches in pamu_domain_init()
  2026-11-30  9:49 ` Jörg Rödel
@ 2026-11-30 14:43   ` fuwh1120
  2026-11-30 18:40     ` Jörg Rödel
  0 siblings, 1 reply; 4+ messages in thread
From: fuwh1120 @ 2026-11-30 14:43 UTC (permalink / raw)
  To: Jörg Rödel; +Cc: will, robin.murphy, jroedel, iommu


Hi,

At 2026-11-30 17:49:27, "Jörg Rödel" <joro@8bytes.org> wrote:
>
>This looks like it deserves a common failure path to get rid of the
>duplication.
>
>-Joerg

Thanks for the feedback! Since the patch has been applied, should
I resend an improved version soon, or wait until this patch is merged
into the mainline before submitting it?

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

* Re: [PATCH] iommu/pamu: Free slab caches in pamu_domain_init()
  2026-11-30 14:43   ` fuwh1120
@ 2026-11-30 18:40     ` Jörg Rödel
  0 siblings, 0 replies; 4+ messages in thread
From: Jörg Rödel @ 2026-11-30 18:40 UTC (permalink / raw)
  To: fuwh1120; +Cc: will, robin.murphy, jroedel, iommu

On Mon, Nov 30, 2026 at 10:43:23PM +0800, fuwh1120 wrote:
> Thanks for the feedback! Since the patch has been applied, should
> I resend an improved version soon, or wait until this patch is merged
> into the mainline before submitting it?

You can send a follow-on based on this patch.

-Joerg

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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  8:59 [PATCH] iommu/pamu: Free slab caches in pamu_domain_init() Wanhui Fu
2026-11-30  9:49 ` Jörg Rödel
2026-11-30 14:43   ` fuwh1120
2026-11-30 18:40     ` 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.