summaryrefslogtreecommitdiff
path: root/arch/mips/sgi-ip22
diff options
context:
space:
mode:
authorXiaoke Wang <xkernel.wang@foxmail.com>2022-03-25 18:57:18 +0800
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>2022-03-30 20:25:11 +0200
commitf93e2a100ee73a4b84d96d7d1881baaac36e586e (patch)
treed62b7f7a926eddeba411642879e554cf99f7e2ea /arch/mips/sgi-ip22
parentf8f9f21c7848e63133c16c899f3d84aa54eb79fe (diff)
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>
Diffstat (limited to 'arch/mips/sgi-ip22')
-rw-r--r--arch/mips/sgi-ip22/ip22-gio.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
index dfc52f661ad0..38d12f417e48 100644
--- a/arch/mips/sgi-ip22/ip22-gio.c
+++ b/arch/mips/sgi-ip22/ip22-gio.c
@@ -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",
slotno, name, id);
gio_dev = kzalloc(sizeof *gio_dev, GFP_KERNEL);
+ if (!gio_dev)
+ return;
gio_dev->name = name;
gio_dev->slotno = slotno;
gio_dev->id.id = id;