diff options
author | Ying Xue <ying.xue@windriver.com> | 2013-12-10 23:45:38 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-12-11 00:17:42 -0500 |
commit | d77b3831f7d59d69aa49d5d1df10bbe56671dc5d (patch) | |
tree | 68ee50f8e762bd9e524502cd6173ee7c50f5949b /net/tipc | |
parent | 4ba3f99a3624187f47f160234fc49a3b8054a0c1 (diff) |
tipc: eliminate redundant code with kfree_skb_list routine
sk_buff lists are currently relased by looping over the list and
explicitly releasing each buffer.
We replace all occurrences of this loop with a call to kfree_skb_list().
Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/link.c | 58 | ||||
-rw-r--r-- | net/tipc/node.c | 6 |
2 files changed, 9 insertions, 55 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c index fd340ad742ea..ac26f8a657d9 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -386,14 +386,7 @@ exit: | |||
386 | */ | 386 | */ |
387 | static void link_release_outqueue(struct tipc_link *l_ptr) | 387 | static void link_release_outqueue(struct tipc_link *l_ptr) |
388 | { | 388 | { |
389 | struct sk_buff *buf = l_ptr->first_out; | 389 | kfree_skb_list(l_ptr->first_out); |
390 | struct sk_buff *next; | ||
391 | |||
392 | while (buf) { | ||
393 | next = buf->next; | ||
394 | kfree_skb(buf); | ||
395 | buf = next; | ||
396 | } | ||
397 | l_ptr->first_out = NULL; | 390 | l_ptr->first_out = NULL; |
398 | l_ptr->out_queue_size = 0; | 391 | l_ptr->out_queue_size = 0; |
399 | } | 392 | } |
@@ -415,32 +408,15 @@ void tipc_link_reset_fragments(struct tipc_link *l_ptr) | |||
415 | */ | 408 | */ |
416 | void tipc_link_stop(struct tipc_link *l_ptr) | 409 | void tipc_link_stop(struct tipc_link *l_ptr) |
417 | { | 410 | { |
418 | struct sk_buff *buf; | 411 | kfree_skb_list(l_ptr->oldest_deferred_in); |
419 | struct sk_buff *next; | 412 | kfree_skb_list(l_ptr->first_out); |
420 | |||
421 | buf = l_ptr->oldest_deferred_in; | ||
422 | while (buf) { | ||
423 | next = buf->next; | ||
424 | kfree_skb(buf); | ||
425 | buf = next; | ||
426 | } | ||
427 | |||
428 | buf = l_ptr->first_out; | ||
429 | while (buf) { | ||
430 | next = buf->next; | ||
431 | kfree_skb(buf); | ||
432 | buf = next; | ||
433 | } | ||
434 | |||
435 | tipc_link_reset_fragments(l_ptr); | 413 | tipc_link_reset_fragments(l_ptr); |
436 | |||
437 | kfree_skb(l_ptr->proto_msg_queue); | 414 | kfree_skb(l_ptr->proto_msg_queue); |
438 | l_ptr->proto_msg_queue = NULL; | 415 | l_ptr->proto_msg_queue = NULL; |
439 | } | 416 | } |
440 | 417 | ||
441 | void tipc_link_reset(struct tipc_link *l_ptr) | 418 | void tipc_link_reset(struct tipc_link *l_ptr) |
442 | { | 419 | { |
443 | struct sk_buff *buf; | ||
444 | u32 prev_state = l_ptr->state; | 420 | u32 prev_state = l_ptr->state; |
445 | u32 checkpoint = l_ptr->next_in_no; | 421 | u32 checkpoint = l_ptr->next_in_no; |
446 | int was_active_link = tipc_link_is_active(l_ptr); | 422 | int was_active_link = tipc_link_is_active(l_ptr); |
@@ -471,12 +447,7 @@ void tipc_link_reset(struct tipc_link *l_ptr) | |||
471 | link_release_outqueue(l_ptr); | 447 | link_release_outqueue(l_ptr); |
472 | kfree_skb(l_ptr->proto_msg_queue); | 448 | kfree_skb(l_ptr->proto_msg_queue); |
473 | l_ptr->proto_msg_queue = NULL; | 449 | l_ptr->proto_msg_queue = NULL; |
474 | buf = l_ptr->oldest_deferred_in; | 450 | kfree_skb_list(l_ptr->oldest_deferred_in); |
475 | while (buf) { | ||
476 | struct sk_buff *next = buf->next; | ||
477 | kfree_skb(buf); | ||
478 | buf = next; | ||
479 | } | ||
480 | if (!list_empty(&l_ptr->waiting_ports)) | 451 | if (!list_empty(&l_ptr->waiting_ports)) |
481 | tipc_link_wakeup_ports(l_ptr, 1); | 452 | tipc_link_wakeup_ports(l_ptr, 1); |
482 | 453 | ||
@@ -1124,10 +1095,7 @@ again: | |||
1124 | if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) { | 1095 | if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) { |
1125 | res = -EFAULT; | 1096 | res = -EFAULT; |
1126 | error: | 1097 | error: |
1127 | for (; buf_chain; buf_chain = buf) { | 1098 | kfree_skb_list(buf_chain); |
1128 | buf = buf_chain->next; | ||
1129 | kfree_skb(buf_chain); | ||
1130 | } | ||
1131 | return res; | 1099 | return res; |
1132 | } | 1100 | } |
1133 | sect_crs += sz; | 1101 | sect_crs += sz; |
@@ -1177,18 +1145,12 @@ error: | |||
1177 | if (l_ptr->max_pkt < max_pkt) { | 1145 | if (l_ptr->max_pkt < max_pkt) { |
1178 | sender->max_pkt = l_ptr->max_pkt; | 1146 | sender->max_pkt = l_ptr->max_pkt; |
1179 | tipc_node_unlock(node); | 1147 | tipc_node_unlock(node); |
1180 | for (; buf_chain; buf_chain = buf) { | 1148 | kfree_skb_list(buf_chain); |
1181 | buf = buf_chain->next; | ||
1182 | kfree_skb(buf_chain); | ||
1183 | } | ||
1184 | goto again; | 1149 | goto again; |
1185 | } | 1150 | } |
1186 | } else { | 1151 | } else { |
1187 | reject: | 1152 | reject: |
1188 | for (; buf_chain; buf_chain = buf) { | 1153 | kfree_skb_list(buf_chain); |
1189 | buf = buf_chain->next; | ||
1190 | kfree_skb(buf_chain); | ||
1191 | } | ||
1192 | return tipc_port_reject_sections(sender, hdr, msg_sect, | 1154 | return tipc_port_reject_sections(sender, hdr, msg_sect, |
1193 | len, TIPC_ERR_NO_NODE); | 1155 | len, TIPC_ERR_NO_NODE); |
1194 | } | 1156 | } |
@@ -2283,11 +2245,7 @@ static int link_send_long_buf(struct tipc_link *l_ptr, struct sk_buff *buf) | |||
2283 | fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE); | 2245 | fragm = tipc_buf_acquire(fragm_sz + INT_H_SIZE); |
2284 | if (fragm == NULL) { | 2246 | if (fragm == NULL) { |
2285 | kfree_skb(buf); | 2247 | kfree_skb(buf); |
2286 | while (buf_chain) { | 2248 | kfree_skb_list(buf_chain); |
2287 | buf = buf_chain; | ||
2288 | buf_chain = buf_chain->next; | ||
2289 | kfree_skb(buf); | ||
2290 | } | ||
2291 | return -ENOMEM; | 2249 | return -ENOMEM; |
2292 | } | 2250 | } |
2293 | msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); | 2251 | msg_set_size(&fragm_hdr, fragm_sz + INT_H_SIZE); |
diff --git a/net/tipc/node.c b/net/tipc/node.c index 25100c0a6fe8..bf1ac89b4806 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -291,11 +291,7 @@ static void node_lost_contact(struct tipc_node *n_ptr) | |||
291 | 291 | ||
292 | /* Flush broadcast link info associated with lost node */ | 292 | /* Flush broadcast link info associated with lost node */ |
293 | if (n_ptr->bclink.recv_permitted) { | 293 | if (n_ptr->bclink.recv_permitted) { |
294 | while (n_ptr->bclink.deferred_head) { | 294 | kfree_skb_list(n_ptr->bclink.deferred_head); |
295 | struct sk_buff *buf = n_ptr->bclink.deferred_head; | ||
296 | n_ptr->bclink.deferred_head = buf->next; | ||
297 | kfree_skb(buf); | ||
298 | } | ||
299 | n_ptr->bclink.deferred_size = 0; | 295 | n_ptr->bclink.deferred_size = 0; |
300 | 296 | ||
301 | if (n_ptr->bclink.reasm_head) { | 297 | if (n_ptr->bclink.reasm_head) { |