Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1817973imm; Sat, 28 Jul 2018 03:39:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpct2BqJ5hp/PCwnalUA5Lp3Hwf0pMZuNjeP3AK4HdBcdSHu9izO2JkNPJ3/D/jFMzYm7CAL X-Received: by 2002:a17:902:1a2:: with SMTP id b31-v6mr9035930plb.279.1532774377528; Sat, 28 Jul 2018 03:39:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532774377; cv=none; d=google.com; s=arc-20160816; b=qplkZ1gXL1NDV6KRs5G1muNv4USTvct94VnaSFOH9iMsgRiGEWQep1FH0418XaeflQ iViOAClfXB8qdQIlqxktgO7tbTLqIYns2LnS/8/TQeQYdoEHtXbAs1+GM/8+CAXF2mZG P9eDLmxWz6FgPIZTVGuU66Sw8kaU/sGasCEVcJX/q+zF4MWfj4V2LtoGwb7fIHM2HuKz Aibxe3kIZvEPoRJPsBnz3Sm7HZNj1tkSF/+Nt8i3EEtUgWDDg357eYayNCgk0kuiiw/3 YfP+KG5iIse2rkehrl0R0VwV9oi68FeMN61IFiW43FB3hp7OnbHKdB5KHxdSzNw/NaHW Oohg== 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:arc-authentication-results; bh=aE5E0icn4r/xJigzpyKlA+1cRgcVgGQEoTgjwfaqB+k=; b=Je68d8q/i4+Ao3trOczdr1z89olevMM7gbt8CMtS/fo/FKVXr/rlv4kOMhJ/wkW8pn Ie3pggaDRmdTrV4gDcm/QkroindLrBqOlCDvJTvNMd1XEIWNkl9hNRLFKfoYiUull5dH MfkXFbY0KVQJ1wCSbPCAhFJkdpXI+GvMFHohwFw18YCjhIxIYcOMkBI89PWVpdj6gwzQ Esz3Zwhy+YIRvRNweE1WIA0M4xWXzfg4nG8hajztjHT20ib4Nb7IP3Zx7KyUrG3a0fll 2YJZMbKpWjeNSorf7wIpGyN/N7s3mBSjyxkZyVvORmc8tPoEJ0MefiajIShrR5GLHave PIaQ== 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 l9-v6si5479748pfe.11.2018.07.28.03.39.23; Sat, 28 Jul 2018 03:39:37 -0700 (PDT) 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 S1728728AbeG1MEj (ORCPT + 99 others); Sat, 28 Jul 2018 08:04:39 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:56149 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728213AbeG1MEj (ORCPT ); Sat, 28 Jul 2018 08:04:39 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id BF975B0AF748F; Sat, 28 Jul 2018 18:38:32 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.382.0; Sat, 28 Jul 2018 18:38:27 +0800 From: YueHaibing To: , , , , , CC: , , YueHaibing Subject: [PATCH net-next] act_bpf: Use kmemdup instead of duplicating it in tcf_bpf_init_from_ops Date: Sat, 28 Jul 2018 18:38:06 +0800 Message-ID: <20180728103806.19592-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.177.31.96] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace calls to kmalloc followed by a memcpy with a direct call to kmemdup. Signed-off-by: YueHaibing --- net/sched/act_bpf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index 06f743d..6203eb0 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -196,12 +196,10 @@ static int tcf_bpf_init_from_ops(struct nlattr **tb, struct tcf_bpf_cfg *cfg) if (bpf_size != nla_len(tb[TCA_ACT_BPF_OPS])) return -EINVAL; - bpf_ops = kzalloc(bpf_size, GFP_KERNEL); + bpf_ops = kmemdup(nla_data(tb[TCA_ACT_BPF_OPS]), bpf_size, GFP_KERNEL); if (bpf_ops == NULL) return -ENOMEM; - memcpy(bpf_ops, nla_data(tb[TCA_ACT_BPF_OPS]), bpf_size); - fprog_tmp.len = bpf_num_ops; fprog_tmp.filter = bpf_ops; -- 2.7.0