[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_33384AA3FF65207ECC63B9531C1F1417E108@qq.com>
Date: Fri, 25 Mar 2022 18:57:18 +0800
From: xkernel.wang@...mail.com
To: tsbogend@...ha.franken.de
Cc: linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org,
Xiaoke Wang <xkernel.wang@...mail.com>
Subject: [PATCH] mips: sgi-ip22: add a check for the return of kzalloc()
From: Xiaoke Wang <xkernel.wang@...mail.com>
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@...mail.com>
---
arch/mips/sgi-ip22/ip22-gio.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
index dfc52f6..38d12f4 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;
--
Powered by blists - more mailing lists