* [PATCH v2] LSM: add NULL check for kcalloc()
@ 2021-07-14 21:51 Austin Kim
0 siblings, 0 replies; only message in thread
From: Austin Kim @ 2021-07-14 21:51 UTC (permalink / raw)
To: jmorris, serge
Cc: linux-security-module, linux-kernel, austin.kim, kernel-team,
austindh.kim
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-14 21:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-14 21:51 [PATCH v2] LSM: add NULL check for kcalloc() Austin Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).