netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6.22.3 4/5] nfnetlink_log: Fix instance_create() failure path
@ 2007-09-21 16:49 Michał Mirosław
  2007-09-24 12:34 ` Patrick McHardy
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Mirosław @ 2007-09-21 16:49 UTC (permalink / raw)
  To: netfilter-devel

Fix memory leak on instance_create() while module is being unloaded.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>                                                               

--- lq3/net/netfilter/nfnetlink_log.c	2007-09-21 18:25:15.000000000 +0200
+++ rechot/net/netfilter/nfnetlink_log.c	2007-09-21 18:24:09.000000000 +0200
@@ -153,6 +153,11 @@
 	if (!inst)
 		goto out_unlock;
 
+	if (!try_module_get(THIS_MODULE)) {
+		kfree(inst);
+		goto out_unlock;
+	}
+
 	INIT_HLIST_NODE(&inst->hlist);
 	spin_lock_init(&inst->lock);
 	/* needs to be two, since we _put() after creation */
@@ -169,9 +174,6 @@
 	inst->copy_mode 	= NFULNL_COPY_PACKET;
 	inst->copy_range 	= 0xffff;
 
-	if (!try_module_get(THIS_MODULE))
-		goto out_free;
-
 	hlist_add_head(&inst->hlist,
 		       &instance_table[instance_hashfn(group_num)]);
 
@@ -182,8 +184,6 @@
 
 	return inst;
 
-out_free:
-	instance_put(inst);
 out_unlock:
 	write_unlock_bh(&instances_lock);
 	return NULL;
-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2007-09-24 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-21 16:49 [PATCH 2.6.22.3 4/5] nfnetlink_log: Fix instance_create() failure path Michał Mirosław
2007-09-24 12:34 ` Patrick McHardy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).