Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5599327rwi; Tue, 18 Oct 2022 01:08:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6hYuWkmlsNNUJ7+p/rY2Qrsi7iZiFtgvvhzt2o9Og8Lxf4NTIH0pv0GDv6Kijdto9sLEtO X-Received: by 2002:a17:906:eec9:b0:783:e662:2513 with SMTP id wu9-20020a170906eec900b00783e6622513mr1379556ejb.656.1666080481912; Tue, 18 Oct 2022 01:08:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666080481; cv=none; d=google.com; s=arc-20160816; b=iff1AxNuhB4S5xBsmKUKEO9ejH2me7UvliKHZs3z/ft1ol60A9R03kDtk8ETS1L4LC giqCJT6uDJb8Ezh4OLlAd6VxvnVs77Z1m1PSw7l+ypT7Qqi+C6+GhKoHDhtppcKFBzzO eYt+ZhSBS87KpqSKeCHBu7eMihu1wSQhzPE3vRKyYDRzfYtmaNIQmL7Y9t3CYWWO7JhB VP7flyRhw01+v6G/cMVidtEl8hlmSF0lE6o+DpC/O1PdbpmgqovfAI824Tqy6J37+mUE 71BueNAF/oxfIaHgqxkOD8e+T5p7EQ06fAcCtKqoIRBoPM+r36wYCs3QgSvLCRn+vCG5 1djQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=GR/gaBvwqXxqf2RzFxupsjbAatya8fM326wE4AQS0d4=; b=zdStEbvFzGF3ITIrjo/KtjlIZyA4kbEhyFzI9QYyBogxWzq2yJHY9Xi8AJSH+pnb+t Qkwr/N0/krjN4IelmaUu7l2NeKBZ/ycJYarDgnACe7wdFKqkvrWls0M+BTzQj4SsdzmU 91dhH3J35gq2vWDZv3QtPsEq+L7p55KzaYNu18dZQxpYf+SC3CCZlqdsQvCwqH2EVbnG kuUUtq0LP5vpB2d3PA8MMbkQokvjuAcfkZVrrt7MmfKutJlO3g/ln/fn5LkYXoRBRiWI Nup0I/GBMzVmRa1sEZeec2X2q/BreP74FoKd2pYoWdk2wEzaQGSsGO7bomQeYTTvJQ2L 7a4Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u8-20020a056402064800b00458cdba7a90si9389775edx.471.2022.10.18.01.07.35; Tue, 18 Oct 2022 01:08:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229928AbiJRH01 (ORCPT + 99 others); Tue, 18 Oct 2022 03:26:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229630AbiJRH00 (ORCPT ); Tue, 18 Oct 2022 03:26:26 -0400 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 12EC01900A; Tue, 18 Oct 2022 00:26:23 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 189201E80D76; Tue, 18 Oct 2022 15:25:42 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gJH4XJN1_3v4; Tue, 18 Oct 2022 15:25:39 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 4B8E81E80D17; Tue, 18 Oct 2022 15:25:39 +0800 (CST) From: Li zeming 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 Subject: [PATCH] integrity: iint: Optimize integrity_iintcache_init and integrity_inode_free function Date: Tue, 18 Oct 2022 15:26:11 +0800 Message-Id: <20221018072611.198802-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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