2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-19 02:34:01 +08:00

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>
This commit is contained in:
Xiaoke Wang 2022-03-25 18:57:18 +08:00 committed by Thomas Bogendoerfer
parent f8f9f21c78
commit f93e2a100e

View File

@ -363,6 +363,8 @@ static void ip22_check_gio(int slotno, unsigned long addr, int irq)
printk(KERN_INFO "GIO: slot %d : %s (id %x)\n", printk(KERN_INFO "GIO: slot %d : %s (id %x)\n",
slotno, name, id); slotno, name, id);
gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL); gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL);
if (!gio_dev)
return;
gio_dev->name = name; gio_dev->name = name;
gio_dev->slotno = slotno; gio_dev->slotno = slotno;
gio_dev->id.id = id; gio_dev->id.id = id;