Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp775266ybl; Wed, 8 Jan 2020 05:44:02 -0800 (PST) X-Google-Smtp-Source: APXvYqyoQ6w1ben/k/dgTL/QYfnX1aZNWjeZG9Z7VtZYQEdKDMO28UQMLltgdrawZlJeAvfnYaZn X-Received: by 2002:aca:4d4f:: with SMTP id a76mr3147948oib.26.1578491042386; Wed, 08 Jan 2020 05:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578491042; cv=none; d=google.com; s=arc-20160816; b=w1It4C4Tjrh/K3pHkHLRbmDvgeDzi3nLMm7Uepc3SF6XNT6bwcLVBVCO/L8Gd4HqL2 qJ9mla3H8DiB5McrRQshW6C62sn0PjS/D9qJtMimQAb3o8cxJ4w59OQjGwG2HLK1nLqO R7CvgNxDhHYw6MOIa/vGvkXeZwYf4sUHk3fe9A+3brVdzWYaES+/rWLvKxskZJ00wzrm SzLKX6My7GTO3D3KWt50yEtiilnOUWuEHHa8Kg5uv+oCAF68lyAr/gSkmVVR65GcI2Uq 2u/TbD0W5qgdEEJpPr0LSHJSf8TUvJJfnuRvQMCbrp+njBnIQaK/3G1ME71OVncdXSdN 8chQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=iOOx9JBhpHjQmx9O+k5JjNvsxqh1WDDnAMxgJrfiqj0=; b=m8nMbEZzHeABTdlLD1sbvOav4nA/Ho2wJ7AYOWdfwiCpHKrjI+J67qagMBScxp0jUy 992QHkRgODIJMDG4VWVPbycUdcCyDBjjlgdVeeGFk48tzEubVxZATegSeccnZnY6fQ7V BciprdkIiTQv1Iu9R4L8OunaowAkkPV1ksPF5q5jFL2N5DwKcCqzri9EdDpGgm2sFcaj HG0O9oJ91V+PApqaqHC6L/m3HA/tV/VAYUs/aSVH1/1P1eASsMZQkTtqtn2P1gVS/W1h XvZWXdIIuclOKqZSuKCNPGwd03un0JWCvAwNlEqQfuY6uxQ720n4KS39GUdSCC2oJyRk C4Lw== 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 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z21si1726389oic.32.2020.01.08.05.43.50; Wed, 08 Jan 2020 05:44:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726808AbgAHL3e (ORCPT + 99 others); Wed, 8 Jan 2020 06:29:34 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:9125 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726098AbgAHL3d (ORCPT ); Wed, 8 Jan 2020 06:29:33 -0500 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 8AAB3A4388C290F79247; Wed, 8 Jan 2020 19:29:31 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Wed, 8 Jan 2020 19:29:24 +0800 From: Chen Zhou To: , , CC: , , Subject: [PATCH] ima: use kmemdup Date: Wed, 8 Jan 2020 19:25:13 +0800 Message-ID: <20200108112513.39715-1-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix memdup.cocci warnings: ./security/integrity/ima/ima_policy.c:268:10-17: WARNING opportunity for kmemdup Use kmemdup rather than duplicating its implementation. Signed-off-by: Chen Zhou --- 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 ef8dfd4..e31649c 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -265,7 +265,7 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry) struct ima_rule_entry *nentry; int i, result; - nentry = kmalloc(sizeof(*nentry), GFP_KERNEL); + nentry = kmemdup(entry, sizeof(*nentry), GFP_KERNEL); if (!nentry) return NULL; @@ -273,7 +273,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.7.4