Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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")
Cc: stable@vger.kernel.org
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Gustavo A. R. Silva and committed by
Thomas Bogendoerfer
792a402c 172a37e9

+3
+3
arch/mips/cavium-octeon/octeon-irq.c
··· 2199 2199 } 2200 2200 2201 2201 cd = kzalloc(sizeof(*cd), GFP_KERNEL); 2202 + if (!cd) 2203 + return -ENOMEM; 2204 + 2202 2205 cd->host_data = host_data; 2203 2206 cd->bit = hw; 2204 2207