lkml.org 
[lkml]   [2021]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] LSM: add NULL check for kcalloc()
From: Austin Kim <austin.kim@lge.com>

kcalloc() may return NULL when memory allocation fails.
So it is necessary to add NULL check after the call to kcalloc() is made.

Signed-off-by: Austin Kim <austin.kim@lge.com>
---
security/security.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/security/security.c b/security/security.c
index 09533cbb7221..f885c9e9bc35 100644
--- a/security/security.c
+++ b/security/security.c
@@ -321,6 +321,8 @@ static void __init ordered_lsm_init(void)

ordered_lsms = kcalloc(LSM_COUNT + 1, sizeof(*ordered_lsms),
GFP_KERNEL);
+ if (ordered_lsms)
+ return;

if (chosen_lsm_order) {
if (chosen_major_lsm) {
--
2.20.1
\
 
 \ /
  Last update: 2021-07-13 01:45    [W:0.053 / U:0.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site