lkml.org 
[lkml]   [2022]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] alpha: add null pointer check
Date
From: Lv Ruyi <lv.ruyi@zte.com.cn>

kmalloc is a memory allocation function which can return NULL when some
internal memory errors happen. Add null pointer check to avoid
dereferencing null pointer.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
---
arch/alpha/kernel/module.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
index 5b60c248de9e..5442b75a98c2 100644
--- a/arch/alpha/kernel/module.c
+++ b/arch/alpha/kernel/module.c
@@ -47,6 +47,8 @@ process_reloc_for_got(Elf64_Rela *rela,
}

g = kmalloc (sizeof (*g), GFP_KERNEL);
+ if (!g)
+ return;
g->next = chains[r_sym].next;
g->r_addend = r_addend;
g->got_offset = *poffset;
--
2.25.1

\
 
 \ /
  Last update: 2022-04-02 10:35    [W:7.815 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site