All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] integrity: iint: Optimize integrity_iintcache_init and integrity_inode_free function
@ 2022-10-18  7:26 Li zeming
  0 siblings, 0 replies; only message in thread
From: Li zeming @ 2022-10-18  7:26 UTC (permalink / raw)
  To: zohar, dmitry.kasatkin, paul, jmorris, serge
  Cc: linux-integrity, linux-security-module, linux-kernel, Li zeming

These functions are optimized as follows.
1. Remove void * variable foo cast type.
2. iint_cache Added memory allocation check.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 security/integrity/iint.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/security/integrity/iint.c b/security/integrity/iint.c
index 8638976f7990..7c902b92482e 100644
--- a/security/integrity/iint.c
+++ b/security/integrity/iint.c
@@ -160,7 +160,7 @@ void integrity_inode_free(struct inode *inode)
 
 static void init_once(void *foo)
 {
-	struct integrity_iint_cache *iint = (struct integrity_iint_cache *) foo;
+	struct integrity_iint_cache *iint = foo;
 
 	memset(iint, 0, sizeof(*iint));
 	iint->ima_file_status = INTEGRITY_UNKNOWN;
@@ -177,6 +177,9 @@ static int __init integrity_iintcache_init(void)
 	iint_cache =
 	    kmem_cache_create("iint_cache", sizeof(struct integrity_iint_cache),
 			      0, SLAB_PANIC, init_once);
+	if (!iint_cache)
+		return -ENOMEM;
+
 	return 0;
 }
 DEFINE_LSM(integrity) = {
-- 
2.18.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-10-18  7:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18  7:26 [PATCH] integrity: iint: Optimize integrity_iintcache_init and integrity_inode_free function Li zeming

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.