Commit aace57e0 authored by Michal Miroslaw's avatar Michal Miroslaw Committed by David S. Miller

[NETFILTER]: nfnetlink_log: fix instance_create() failure path

Fix memory leak on instance_create() while module is being unloaded.
Signed-off-by: default avatarMichal Miroslaw <mirq-linux@rere.qmqm.pl>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c6a8f648
...@@ -152,6 +152,11 @@ instance_create(u_int16_t group_num, int pid) ...@@ -152,6 +152,11 @@ instance_create(u_int16_t group_num, int pid)
if (!inst) if (!inst)
goto out_unlock; goto out_unlock;
if (!try_module_get(THIS_MODULE)) {
kfree(inst);
goto out_unlock;
}
INIT_HLIST_NODE(&inst->hlist); INIT_HLIST_NODE(&inst->hlist);
spin_lock_init(&inst->lock); spin_lock_init(&inst->lock);
/* needs to be two, since we _put() after creation */ /* needs to be two, since we _put() after creation */
...@@ -168,9 +173,6 @@ instance_create(u_int16_t group_num, int pid) ...@@ -168,9 +173,6 @@ instance_create(u_int16_t group_num, int pid)
inst->copy_mode = NFULNL_COPY_PACKET; inst->copy_mode = NFULNL_COPY_PACKET;
inst->copy_range = 0xffff; inst->copy_range = 0xffff;
if (!try_module_get(THIS_MODULE))
goto out_free;
hlist_add_head(&inst->hlist, hlist_add_head(&inst->hlist,
&instance_table[instance_hashfn(group_num)]); &instance_table[instance_hashfn(group_num)]);
...@@ -181,8 +183,6 @@ instance_create(u_int16_t group_num, int pid) ...@@ -181,8 +183,6 @@ instance_create(u_int16_t group_num, int pid)
return inst; return inst;
out_free:
instance_put(inst);
out_unlock: out_unlock:
write_unlock_bh(&instances_lock); write_unlock_bh(&instances_lock);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment