public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [irqchip] mips-cpu: Add error handling in mips_cpu_register_ipi_domain
@ 2023-11-30  4:06 Haoran Liu
  2023-12-08 14:13 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Haoran Liu @ 2023-11-30  4:06 UTC (permalink / raw)
  To: tsbogend; +Cc: fancer.lancer, tglx, linux-mips, linux-kernel, Haoran Liu

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@163.com>
---
 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


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

* Re: [PATCH] [irqchip] mips-cpu: Add error handling in mips_cpu_register_ipi_domain
  2023-11-30  4:06 [PATCH] [irqchip] mips-cpu: Add error handling in mips_cpu_register_ipi_domain Haoran Liu
@ 2023-12-08 14:13 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2023-12-08 14:13 UTC (permalink / raw)
  To: Haoran Liu, tsbogend; +Cc: fancer.lancer, linux-mips, linux-kernel, Haoran Liu

On Wed, Nov 29 2023 at 20:06, Haoran Liu wrote:

The subject line:

  https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#patch-subject

> This patch enhances the mips_cpu_register_ipi_domain function in

# git grep 'This patch' Documentation/process/

> drivers/irqchip/irq-mips-cpu.c by adding error handling for the
> kzalloc

The file name is irrelevant. Please read and follow:

  https://www.kernel.org/doc/html/latest/process/maintainer-tip.html

> call. Previously, the function lacked proper handling for kzalloc
> failures, which could lead to potential null pointer dereference issues
> under low memory conditions.

The value of this "enhancement" is dubious. if that kzalloc() fails then
any subsequent allocation will fail too and the machine will crash
anyway.


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

end of thread, other threads:[~2023-12-08 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-30  4:06 [PATCH] [irqchip] mips-cpu: Add error handling in mips_cpu_register_ipi_domain Haoran Liu
2023-12-08 14:13 ` Thomas Gleixner

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