Skip to content

Commit

Permalink
MIPS: OCTEON: irq: Fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
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: 64b139f ("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>
  • Loading branch information
Gustavo A. R. Silva authored and Thomas Bogendoerfer committed Mar 4, 2020
1 parent 172a37e commit 792a402
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/mips/cavium-octeon/octeon-irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 792a402

Please sign in to comment.