Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755927AbbHGIFE (ORCPT ); Fri, 7 Aug 2015 04:05:04 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:23247 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422659AbbHGIAt (ORCPT ); Fri, 7 Aug 2015 04:00:49 -0400 X-AuditID: cbfec7f5-f794b6d000001495-3c-55c465afc02a From: Andrzej Hajda To: Jamal Hadi Salim , "David S. Miller" Cc: Andrzej Hajda , Bartlomiej Zolnierkiewicz , Marek Szyprowski , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH 26/31] net/sched: use kmemdup rather than duplicating its implementation Date: Fri, 07 Aug 2015 09:59:32 +0200 Message-id: <1438934377-4922-27-git-send-email-a.hajda@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> References: <1438934377-4922-1-git-send-email-a.hajda@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjluLIzCtJLcpLzFFi42I5/e/4Fd31qUdCDf60KljcWneO1WLjjPWs FnPOt7BYbPiyhd3i8q45bBZrj9xltzi2QMyB3WPLyptMHtturWX16NuyitHj8ya5AJYoLpuU 1JzMstQifbsErow1XboFTTwVt1YuZ2lg7OPqYuTkkBAwkWjeM4sVwhaTuHBvPVsXIxeHkMBS Ron2t9NZIZwmJokHlzcwgVSxCWhK/N18kw3EFhEIkDjZsIkRpIhZ4BijxKYN08FGCQtESUzf fYEFxGYRUJWY9vggO4jNK+As8XLiNDaIdXISJ49NBqvnBIqv7J4JZgsJOEm86bvAPIGRdwEj wypG0dTS5ILipPRcI73ixNzi0rx0veT83E2MkFD6uoNx6TGrQ4wCHIxKPLwJ/w6HCrEmlhVX 5h5ilOBgVhLhfagPFOJNSaysSi3Kjy8qzUktPsQozcGiJM47c9f7ECGB9MSS1OzU1ILUIpgs EwenVAPjtSz/K5/Y/tQutlO5fOvGQcH3m8pcg/wuKqzpSj355OyCijd7T59ee7jhLseLsBDu ebvmlLClXPqxYcaPN1Hmfhu9n786eNWh9OjfUydK94T8nvbjtPGTqQ6cJxZMr6tZpXqll192 hQRzinVIvu+K+qWq2YFbeX+7fW2ZNDX735uiNerdiufSTZRYijMSDbWYi4oTAd8/EichAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1733 Lines: 55 The patch was generated using fixed coccinelle semantic patch scripts/coccinelle/api/memdup.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2014320 Signed-off-by: Andrzej Hajda --- net/sched/act_bpf.c | 4 +--- net/sched/cls_bpf.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/net/sched/act_bpf.c b/net/sched/act_bpf.c index 1b97dab..5c0fa03 100644 --- a/net/sched/act_bpf.c +++ b/net/sched/act_bpf.c @@ -190,12 +190,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; diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c index e5168f8..423f774 100644 --- a/net/sched/cls_bpf.c +++ b/net/sched/cls_bpf.c @@ -212,12 +212,10 @@ static int cls_bpf_prog_from_ops(struct nlattr **tb, 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; -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/