linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Li zeming <zeming@nfschina.com>
To: zohar@linux.ibm.com, dmitry.kasatkin@gmail.com,
	paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com
Cc: linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org, Li zeming <zeming@nfschina.com>
Subject: [PATCH] integrity: iint: Optimize integrity_iintcache_init and integrity_inode_free function
Date: Tue, 18 Oct 2022 15:26:11 +0800	[thread overview]
Message-ID: <20221018072611.198802-1-zeming@nfschina.com> (raw)

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


                 reply	other threads:[~2022-10-18  7:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221018072611.198802-1-zeming@nfschina.com \
    --to=zeming@nfschina.com \
    --cc=dmitry.kasatkin@gmail.com \
    --cc=jmorris@namei.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).