Skip to contentSkip to conversation

nfnetlink_log: Fix instance_create() failure path

PATCH In review Michał Mirosław 2 participants 2 messages Sep 21, 2007 – Sep 24, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 4/5 nfnetlink_log: Fix instance_create() failure path

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

net/netfilter/nfnetlink_log.c +5 -5
@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html