lkml.org 
[lkml]   [2022]   [Jun]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] smackfs: check for allocation failure of kmalloc()
Date
As the possible failure of the kmalloc(), it should be better
to check it and print a warning message.

Signed-off-by: Li Qiong <liqiong@nfschina.com>
---
security/smack/smackfs.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 4b58526450d4..0d11ba3cb4cd 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -695,6 +695,11 @@ static void smk_cipso_doi(void)
__func__, __LINE__, rc);

doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL | __GFP_NOFAIL);
+ if (unlikely(!doip)) {
+ printk(KERN_WARNING "%s:%d failed to allocate a memory for doip\n",
+ __func__, __LINE__);
+ return;
+ }
doip->map.std = NULL;
doip->doi = smk_cipso_doi_value;
doip->type = CIPSO_V4_MAP_PASS;
--
2.25.1
\
 
 \ /
  Last update: 2022-06-13 08:23    [W:0.062 / U:0.128 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site