Skip to contentSkip to conversation

MIPS: OCTEON: irq: Fix potential NULL pointer dereference

PATCH New Gustavo A. R. Silva 1 participant 1 message Jan 22, 2019 MIPS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: OCTEON: irq: Fix potential NULL pointer dereference

There is a potential NULL pointer dereference in case kzalloc() fails and returns NULL.

Fix this by adding a NULL check on *cd*

This bug was detected with the help of Coccinelle.

Fixes 64b139f97c01 ("MIPS: OCTEON: irq: add CIB and other fixes")
---
 arch/mips/cavium-octeon/octeon-irq.c | 3 +++
 1 file changed, 3 insertions(+)
arch/mips/cavium-octeon/octeon-irq.c +3 -0
index f97be32bf699..3ad1f76c063a 100644
@@ -2199,6 +2199,9 @@ static int octeon_irq_cib_map(struct irq_domain *d,
 	}
 
 	cd = kzalloc(sizeof(*cd), GFP_KERNEL);
+	if (!cd)
+		return -ENOMEM;
+
 	cd->host_data = host_data;
 	cd->bit = hw;
 
Signature · 1 line
2.20.1