public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cleanup for net/tipc/name_distr.c::tipc_named_node_up()
@ 2006-03-18 23:45 Jesper Juhl
  2006-03-22  9:56 ` Per Liden
  0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2006-03-18 23:45 UTC (permalink / raw)
  To: linux-kernel
  Cc: Per Liden, Jon Maloy, Allan Stephens, tipc-discussion,
	Jesper Juhl


Small cleanup patch for net/tipc/name_distr.c::tipc_named_node_up()

Patch does the following:

 - Change a few pointer assignments from 0 to NULL (makes sparse happy).
 - Move a few variable assignment outside the tipc_nametbl_lock lock.
 - Make sure to free the allocated buffer before returning so we don't leak.


Note: patch is compile tested only and I'm not familiar with this code, so
      please check my changes carefully.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 net/tipc/name_distr.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

--- linux-2.6.16-rc6-orig/net/tipc/name_distr.c	2006-03-12 14:19:18.000000000 +0100
+++ linux-2.6.16-rc6/net/tipc/name_distr.c	2006-03-19 00:36:41.000000000 +0100
@@ -168,17 +168,17 @@ void tipc_named_withdraw(struct publicat
 void tipc_named_node_up(unsigned long node)
 {
 	struct publication *publ;
-	struct distr_item *item = 0;
-	struct sk_buff *buf = 0;
+	struct distr_item *item = NULL;
+	struct sk_buff *buf = NULL;
 	u32 left = 0;
 	u32 rest;
 	u32 max_item_buf;
 
 	assert(in_own_cluster(node));
-	read_lock_bh(&tipc_nametbl_lock); 
 	max_item_buf = TIPC_MAX_USER_MSG_SIZE / ITEM_SIZE;
 	max_item_buf *= ITEM_SIZE;
 	rest = publ_cnt * ITEM_SIZE;
+	read_lock_bh(&tipc_nametbl_lock); 
 
 	list_for_each_entry(publ, &publ_root, local_list) {
 		if (!buf) {
@@ -200,10 +200,11 @@ void tipc_named_node_up(unsigned long no
 			    "<%u.%u.%u>\n", tipc_zone(node), 
 			    tipc_cluster(node), tipc_node(node));
 			tipc_link_send(buf, node, node);
-			buf = 0;
+			buf = NULL;
 		}
 	}
 exit:
+	kfree_skb(buf);
 	read_unlock_bh(&tipc_nametbl_lock); 
 }
 




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-03-27 12:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-03-18 23:45 [PATCH] cleanup for net/tipc/name_distr.c::tipc_named_node_up() Jesper Juhl
2006-03-22  9:56 ` Per Liden
2006-03-26 11:35   ` Jesper Juhl
2006-03-27 12:13     ` Per Liden

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox