[PATCH] [irqchip] mips-cpu: Add error handling in mips_cpu_register_ipi_domain
From: Haoran Liu
Date: Wed Nov 29 2023 - 23:07:25 EST
This patch enhances the mips_cpu_register_ipi_domain function in
drivers/irqchip/irq-mips-cpu.c by adding error handling for the kzalloc
call. Previously, the function lacked proper handling for kzalloc
failures, which could lead to potential null pointer dereference issues
under low memory conditions.
Signed-off-by: Haoran Liu <liuhaoran14@xxxxxxx>
---
drivers/irqchip/irq-mips-cpu.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/irqchip/irq-mips-cpu.c b/drivers/irqchip/irq-mips-cpu.c
index 0c7ae71a0af0..a8030c2b135c 100644
--- a/drivers/irqchip/irq-mips-cpu.c
+++ b/drivers/irqchip/irq-mips-cpu.c
@@ -238,6 +238,9 @@ static void mips_cpu_register_ipi_domain(struct device_node *of_node)
struct cpu_ipi_domain_state *ipi_domain_state;
ipi_domain_state = kzalloc(sizeof(*ipi_domain_state), GFP_KERNEL);
+ if (!ipi_domain_state)
+ panic("Failed to allocate MIPS CPU IPI domain state");
+
ipi_domain = irq_domain_add_hierarchy(irq_domain,
IRQ_DOMAIN_FLAG_IPI_SINGLE,
2, of_node,
--
2.17.1