From patchwork Fri Dec 6 06:23:37 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangweidong X-Patchwork-Id: 297593 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id E79442C009F for ; Fri, 6 Dec 2013 17:24:16 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756451Ab3LFGYP (ORCPT ); Fri, 6 Dec 2013 01:24:15 -0500 Received: from szxga01-in.huawei.com ([119.145.14.64]:45069 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756179Ab3LFGX7 (ORCPT ); Fri, 6 Dec 2013 01:23:59 -0500 Received: from 172.24.2.119 (EHLO szxeml210-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BNX31246; Fri, 06 Dec 2013 14:23:49 +0800 (CST) Received: from SZXEML453-HUB.china.huawei.com (10.82.67.196) by szxeml210-edg.china.huawei.com (172.24.2.183) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 6 Dec 2013 14:23:45 +0800 Received: from localhost (10.135.68.79) by SZXEML453-HUB.china.huawei.com (10.82.67.196) with Microsoft SMTP Server id 14.3.158.1; Fri, 6 Dec 2013 14:23:43 +0800 From: Wang Weidong To: , , CC: , Subject: [PATCH net-next 1/6] tipc: add link_kfree_skbuff helper function Date: Fri, 6 Dec 2013 14:23:37 +0800 Message-ID: <1386311022-11176-2-git-send-email-wangweidong1@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 In-Reply-To: <1386311022-11176-1-git-send-email-wangweidong1@huawei.com> References: <1386311022-11176-1-git-send-email-wangweidong1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.135.68.79] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org replaces some chunks of code that kfree the sk_buff. This is just code simplification, no functional changes. Signed-off-by: Wang Weidong --- net/tipc/link.c | 58 +++++++++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/net/tipc/link.c b/net/tipc/link.c index 69cd9bf..1c27d7b 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c @@ -100,6 +100,17 @@ static unsigned int align(unsigned int i) return (i + 3) & ~3u; } +static void link_kfree_skbuff(struct sk_buff *buf) +{ + struct sk_buff *next; + + while (buf) { + next = buf->next; + kfree_skb(buf); + buf = next; + } +} + static void link_init_max_pkt(struct tipc_link *l_ptr) { u32 max_pkt; @@ -387,13 +398,8 @@ exit: static void link_release_outqueue(struct tipc_link *l_ptr) { struct sk_buff *buf = l_ptr->first_out; - struct sk_buff *next; - while (buf) { - next = buf->next; - kfree_skb(buf); - buf = next; - } + link_kfree_skbuff(buf); l_ptr->first_out = NULL; l_ptr->out_queue_size = 0; } @@ -416,21 +422,12 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr) void tipc_link_stop(struct tipc_link *l_ptr) { struct sk_buff *buf; - struct sk_buff *next; buf = l_ptr->oldest_deferred_in; - while (buf) { - next = buf->next; - kfree_skb(buf); - buf = next; - } + link_kfree_skbuff(buf); buf = l_ptr->first_out; - while (buf) { - next = buf->next; - kfree_skb(buf); - buf = next; - } + link_kfree_skbuff(buf); tipc_link_reset_fragments(l_ptr); @@ -472,11 +469,7 @@ void tipc_link_reset(struct tipc_link *l_ptr) kfree_skb(l_ptr->proto_msg_queue); l_ptr->proto_msg_queue = NULL; buf = l_ptr->oldest_deferred_in; - while (buf) { - struct sk_buff *next = buf->next; - kfree_skb(buf); - buf = next; - } + link_kfree_skbuff(buf); if (!list_empty(&l_ptr->waiting_ports)) tipc_link_wakeup_ports(l_ptr, 1); @@ -1127,10 +1120,7 @@ again: if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) { res = -EFAULT; error: - for (; buf_chain; buf_chain = buf) { - buf = buf_chain->next; - kfree_skb(buf_chain); - } + link_kfree_skbuff(buf_chain); return res; } sect_crs += sz; @@ -1180,18 +1170,12 @@ error: if (l_ptr->max_pkt < max_pkt) { sender->max_pkt = l_ptr->max_pkt; tipc_node_unlock(node); - for (; buf_chain; buf_chain = buf) { - buf = buf_chain->next; - kfree_skb(buf_chain); - } + link_kfree_skbuff(buf_chain); goto again; } } else { reject: - for (; buf_chain; buf_chain = buf) { - buf = buf_chain->next; - kfree_skb(buf_chain); - } + link_kfree_skbuff(buf_chain); return tipc_port_reject_sections(sender, hdr, msg_sect, len, TIPC_ERR_NO_NODE); } @@ -2306,11 +2290,7 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE); if (fragm == NULL) { kfree_skb(buf); - while (buf_chain) { - buf = buf_chain; - buf_chain = buf_chain->next; - kfree_skb(buf); - } + link_kfree_skbuff(buf_chain); return -ENOMEM; } msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE);