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

mips: sgi-ip22: add a check for the return of kzalloc()

kzalloc() is a memory allocation function which can return NULL when
some internal memory errors happen. So it is better to check it to
prevent potential wrong memory access.

Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>

authored by

Xiaoke Wang and committed by
Thomas Bogendoerfer
f93e2a10 f8f9f21c

+2
+2
arch/mips/sgi-ip22/ip22-gio.c
··· 363 363 printk(KERN_INFO "GIO: slot %d : %s (id %x)\n", 364 364 slotno, name, id); 365 365 gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL); 366 + if (!gio_dev) 367 + return; 366 368 gio_dev->name = name; 367 369 gio_dev->slotno = slotno; 368 370 gio_dev->id.id = id;