[irqchip: irq/irqchip-next] irqchip/wpcm450: Fix memory leak in wpcm450_aic_of_init()

From: irqchip-bot for Wei Yongjun
Date: Sat Nov 26 2022 - 08:34:40 EST


The following commit has been merged into the irq/irqchip-next branch of irqchip:

Commit-ID: 4208d4faf36573a507b5e5de17abe342e9276759
Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/4208d4faf36573a507b5e5de17abe342e9276759
Author: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
AuthorDate: Tue, 15 Nov 2022 09:25:32
Committer: Marc Zyngier <maz@xxxxxxxxxx>
CommitterDate: Sat, 26 Nov 2022 13:29:48

irqchip/wpcm450: Fix memory leak in wpcm450_aic_of_init()

If of_iomap() failed, 'aic' should be freed before return. Otherwise
there is a memory leak.

Fixes: fead4dd49663 ("irqchip: Add driver for WPCM450 interrupt controller")
Signed-off-by: Wei Yongjun <weiyongjun1@xxxxxxxxxx>
Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@xxxxxxx>
Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20221115092532.1704032-1-weiyongjun@xxxxxxxxxxxxxxx
---
drivers/irqchip/irq-wpcm450-aic.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/irqchip/irq-wpcm450-aic.c b/drivers/irqchip/irq-wpcm450-aic.c
index 0dcbeb1..91df62a 100644
--- a/drivers/irqchip/irq-wpcm450-aic.c
+++ b/drivers/irqchip/irq-wpcm450-aic.c
@@ -146,6 +146,7 @@ static int __init wpcm450_aic_of_init(struct device_node *node,
aic->regs = of_iomap(node, 0);
if (!aic->regs) {
pr_err("Failed to map WPCM450 AIC registers\n");
+ kfree(aic);
return -ENOMEM;
}