Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1816011imm; Sat, 28 Jul 2018 03:36:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeTgAP8GrebLepPXmliUhN0+PxliMcJY7KE2hkoPpgXwIEwW00LQdm6+jBSZaku0pB4nA7/ X-Received: by 2002:a17:902:d218:: with SMTP id t24-v6mr9377109ply.63.1532774212484; Sat, 28 Jul 2018 03:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532774212; cv=none; d=google.com; s=arc-20160816; b=ZWLWpoaY89GRwBKTmObhiSv8dQZAeLa9+GyWlxc5MjaPyJOcgcr97lR/OhcSnInRjd UOaBbgWDHaM3JSmyxPTMMPAuabfu98TvsJNErsft1fdn1TK51J90PKL2kkT1Ls/VScW2 bWF4Ryx7NxV20LRIL6lcnCNtLhdwYgtlzODt06sYjKEXpfdZ0MRvUyDwdlRYZy2bUnaL 56AAd4BMijE46BDLwmI5Usvj4o7M0AjUaWYZVKHhVlp7j0SEGsyUVV703E3zJsXxEgda MfB+H4L1LAYhER6UZzhLX+jaCO9rUjet7mz5KR8D8Pz0e6dkPRxOuNEm7rU8tI+FHRPT /x6A== 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=XScmZa/FxKVzZdiC40+Jk/dZW1y4KdkEPs2sMDmIxKo=; b=v4cheju2jVoEso5xn0QUC25nnDx3/NkGMcmrbZrecN6C5IkTN0uwrJavlPRXN41WJO CnNgkwWe+Gsr8J1my6hyBFjhdwJagYeLL3TU8uLaBDmLgZj9dWsMBRmJnx54le3ox5Us rTGD09BuScMjRE+o8ZCSzjuVIFu3jfP2vGSjjFizjVRWZg+8D6hPHwK3PbhlNX4pMgpE qTGRa+aPDvym+hYFRBaPRyXk4/56Mz8m2H2HrhfspvSPkpbubAfKEpmwhlUwVEaG36Y4 RBdhDqGuOKZREjgU1AjdAWk+tLruetX1hDeBiF7dir3JK3mF2MmmBvFj6CSpGny1qRFp v/Pw== 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 68-v6si5735335pga.113.2018.07.28.03.36.37; Sat, 28 Jul 2018 03:36:52 -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 S1728648AbeG1MBy (ORCPT + 99 others); Sat, 28 Jul 2018 08:01:54 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:55377 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728449AbeG1MBy (ORCPT ); Sat, 28 Jul 2018 08:01:54 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id EC21EA62C749B; Sat, 28 Jul 2018 18:35:43 +0800 (CST) Received: from localhost (10.177.31.96) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.382.0; Sat, 28 Jul 2018 18:35:37 +0800 From: YueHaibing To: , , , , , CC: , , YueHaibing Subject: [PATCH net-next] cls_bpf: Use kmemdup instead of duplicating it in cls_bpf_prog_from_ops Date: Sat, 28 Jul 2018 18:35:15 +0800 Message-ID: <20180728103515.8576-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/cls_bpf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index 66e0ac9..fa6fe2f 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -349,12 +349,10 @@ static int cls_bpf_prog_from_ops(struct nlattr **tb, struct cls_bpf_prog *prog) if (bpf_size != nla_len(tb[TCA_BPF_OPS])) return -EINVAL; - bpf_ops = kzalloc(bpf_size, GFP_KERNEL); + bpf_ops = kmemdup(nla_data(tb[TCA_BPF_OPS]), bpf_size, GFP_KERNEL); if (bpf_ops == NULL) return -ENOMEM; - memcpy(bpf_ops, nla_data(tb[TCA_BPF_OPS]), bpf_size); - fprog_tmp.len = bpf_num_ops; fprog_tmp.filter = bpf_ops; -- 2.7.0