Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp424181ybz; Wed, 15 Apr 2020 11:18:55 -0700 (PDT) X-Google-Smtp-Source: APiQypIfTp5Xrtx9BOfXIRbuToNoetONHxXfA2pJ1jk5DNKGeA50hrwFSh5q7h8iiNYUG1RffSgH X-Received: by 2002:aa7:c40c:: with SMTP id j12mr4219718edq.169.1586974735626; Wed, 15 Apr 2020 11:18:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586974735; cv=none; d=google.com; s=arc-20160816; b=Ee5e+1Im00wxYKURexdMRybqf7rx7DJ6mDrsNWfJzQkQ3DpL/i93+mdC/pNMyWyxtL NoxzTZYe49gzuyjI2GS7osyldVclIDD462XDZTHn+IZILcEGbxGXutnDUTHkN9AuA4u1 GM2x6ix2oO6QodwqkvZa2uwFHengYU9vgZSeaeKyUSrtoGY6BETQpvmmTnQjcQVY4j1T 6vfGAgPTmE9wUEj/zJyAN9yzpwDNdXxymkTh0v7MaPKbsuNS+xa0JIWrBs5AdpAmsIAb H7chZLdbs3j8LuaTipSn9yS73OLZo1vA/occvGCkwV3WlQL0dIakrdNsWkPWZL/q9l/A Jf/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=HHaWioulr+a2B1ptWAr3QoB63hvm+vMgRWiUji4BRT0=; b=owgUvsS8AVbKq5TGUiLv6WkPu8pTvReEl8wQ3lxdxMKGuTSpy13DAqbrX9PqFETfst Q6ZCT/0PzaNKIvjdbDIlnUlPP1nRRjsKqYO+KtnujMvb2IlOH1DyUOYv61GDaiKXoP1z VGnEImyVKrv2jpjHjuNnsjw6PZVmnsIz22b5sc3KquSCQsvsnmzj+2lAexrpVc7SFboN Rp99eywdnUqUHMrZCA0brGGJp4+cyDNP/qmGsilzr32/NILu2G9w0dABpFatA/7kcOCi 5zignC+kEWvCCzNqcDcRDnxjIFHrC9c4c/qXpWUdNhTqisMfayMVPg+WsXQ000i2oosT JxUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m18si10168864eda.110.2020.04.15.11.18.29; Wed, 15 Apr 2020 11:18:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407098AbgDNIRU (ORCPT + 99 others); Tue, 14 Apr 2020 04:17:20 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:57892 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2407079AbgDNIRP (ORCPT ); Tue, 14 Apr 2020 04:17:15 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7CDE2362AE5C6C96C2F8; Tue, 14 Apr 2020 16:16:59 +0800 (CST) Received: from linux-lmwb.huawei.com (10.175.103.112) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Tue, 14 Apr 2020 16:15:35 +0800 From: Zou Wei To: , , , , , , CC: Zou Wei Subject: [PATCH -next] IMA: fix memdup.cocci warnings Date: Tue, 14 Apr 2020 16:21:59 +0800 Message-ID: <1586852519-69161-1-git-send-email-zou_wei@huawei.com> X-Mailer: git-send-email 2.6.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.103.112] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixes coccicheck warning: security/integrity/ima/ima_policy.c:272:10-17: WARNING opportunity for kmemdup Use kmemdup rather than duplicating its implementation Reported-by: Hulk Robot Signed-off-by: Zou Wei --- security/integrity/ima/ima_policy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index c334e0d..185f8d7 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -269,7 +269,7 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry) struct ima_rule_entry *nentry; int i; - nentry = kmalloc(sizeof(*nentry), GFP_KERNEL); + nentry = kmemdup(entry, sizeof(*nentry), GFP_KERNEL); if (!nentry) return NULL; @@ -277,7 +277,6 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry) * Immutable elements are copied over as pointers and data; only * lsm rules can change */ - memcpy(nentry, entry, sizeof(*nentry)); memset(nentry->lsm, 0, sizeof_field(struct ima_rule_entry, lsm)); for (i = 0; i < MAX_LSM_RULES; i++) { -- 2.6.2