Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] irqchip/atmel-aic5: Free SMR cache on init failure
@ 2026-05-13 23:31 Yuho Choi
  2026-05-15  9:58 ` Nicolas Ferre
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-05-13 23:31 UTC (permalink / raw)
  To: Thomas Gleixner, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
  Cc: linux-kernel, linux-arm-kernel, Yuho Choi

sama5d2_aic5_of_init() allocates the SMR cache before calling
aic5_of_init(). If that fails, the cache is left allocated even though
no IRQ domain was installed and the cache will not be used.

Free the cache on the failure path and clear the global pointer.

Fixes: a50ac562ef48 ("irqchip/atmel-aic5: Handle suspend to RAM")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
---
 drivers/irqchip/irq-atmel-aic5.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
index 1f14b401f71d..58650eb16880 100644
--- a/drivers/irqchip/irq-atmel-aic5.c
+++ b/drivers/irqchip/irq-atmel-aic5.c
@@ -358,13 +358,22 @@ static int __init sama5d2_aic5_of_init(struct device_node *node,
 				       struct device_node *parent)
 {
 #ifdef CONFIG_PM
+	int rc = 0;
 	smr_cache = kcalloc(DIV_ROUND_UP(NR_SAMA5D2_IRQS, 32) * 32,
 			    sizeof(*smr_cache), GFP_KERNEL);
 	if (!smr_cache)
 		return -ENOMEM;
-#endif
 
+	rc = aic5_of_init(node, parent, NR_SAMA5D2_IRQS);
+	if (rc) {
+		kfree(smr_cache);
+		smr_cache = NULL;
+	}
+
+	return rc;
+#else
 	return aic5_of_init(node, parent, NR_SAMA5D2_IRQS);
+#endif
 }
 IRQCHIP_DECLARE(sama5d2_aic5, "atmel,sama5d2-aic", sama5d2_aic5_of_init);
 
-- 
2.43.0



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

* Re: [PATCH v1] irqchip/atmel-aic5: Free SMR cache on init failure
  2026-05-13 23:31 [PATCH v1] irqchip/atmel-aic5: Free SMR cache on init failure Yuho Choi
@ 2026-05-15  9:58 ` Nicolas Ferre
  0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Ferre @ 2026-05-15  9:58 UTC (permalink / raw)
  To: Yuho Choi, Thomas Gleixner, Alexandre Belloni, Claudiu Beznea
  Cc: linux-kernel, linux-arm-kernel

On 14/05/2026 at 01:31, Yuho Choi wrote:
> sama5d2_aic5_of_init() allocates the SMR cache before calling
> aic5_of_init(). If that fails, the cache is left allocated even though
> no IRQ domain was installed and the cache will not be used.
> 
> Free the cache on the failure path and clear the global pointer.

No aic5 = no viable system to run on: I'm not sure it's worth 
considering the case.

> Fixes: a50ac562ef48 ("irqchip/atmel-aic5: Handle suspend to RAM")
> Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
> ---
>   drivers/irqchip/irq-atmel-aic5.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/irqchip/irq-atmel-aic5.c b/drivers/irqchip/irq-atmel-aic5.c
> index 1f14b401f71d..58650eb16880 100644
> --- a/drivers/irqchip/irq-atmel-aic5.c
> +++ b/drivers/irqchip/irq-atmel-aic5.c
> @@ -358,13 +358,22 @@ static int __init sama5d2_aic5_of_init(struct device_node *node,
>                                         struct device_node *parent)
>   {
>   #ifdef CONFIG_PM
> +       int rc = 0;
>          smr_cache = kcalloc(DIV_ROUND_UP(NR_SAMA5D2_IRQS, 32) * 32,
>                              sizeof(*smr_cache), GFP_KERNEL);
>          if (!smr_cache)
>                  return -ENOMEM;
> -#endif
> 
> +       rc = aic5_of_init(node, parent, NR_SAMA5D2_IRQS);
> +       if (rc) {
> +               kfree(smr_cache);
> +               smr_cache = NULL;
> +       }
> +
> +       return rc;
> +#else
>          return aic5_of_init(node, parent, NR_SAMA5D2_IRQS);
> +#endif
>   }
>   IRQCHIP_DECLARE(sama5d2_aic5, "atmel,sama5d2-aic", sama5d2_aic5_of_init);
> 
> --
> 2.43.0
> 



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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-13 23:31 [PATCH v1] irqchip/atmel-aic5: Free SMR cache on init failure Yuho Choi
2026-05-15  9:58 ` Nicolas Ferre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox