aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Miroslaw <mirq-linux@rere.qmqm.pl>2007-09-28 17:45:27 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:53:39 -0400
commitaace57e054e9322e20af52cede7de46ade64a5e2 (patch)
treec6f0b82a6c658bb6796cdb84e36bc1d388d87bef
parentc6a8f648362a5d8b934f4267b0ab9f255c130ab0 (diff)
[NETFILTER]: nfnetlink_log: fix instance_create() failure path
Fix memory leak on instance_create() while module is being unloaded. Signed-off-by: Michal Miroslaw <mirq-linux@rere.qmqm.pl> Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/netfilter/nfnetlink_log.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index d2e811f46067..16ae53918606 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -152,6 +152,11 @@ instance_create(u_int16_t group_num, int pid)
152 if (!inst) 152 if (!inst)
153 goto out_unlock; 153 goto out_unlock;
154 154
155 if (!try_module_get(THIS_MODULE)) {
156 kfree(inst);
157 goto out_unlock;
158 }
159
155 INIT_HLIST_NODE(&inst->hlist); 160 INIT_HLIST_NODE(&inst->hlist);
156 spin_lock_init(&inst->lock); 161 spin_lock_init(&inst->lock);
157 /* needs to be two, since we _put() after creation */ 162 /* needs to be two, since we _put() after creation */
@@ -168,9 +173,6 @@ instance_create(u_int16_t group_num, int pid)
168 inst->copy_mode = NFULNL_COPY_PACKET; 173 inst->copy_mode = NFULNL_COPY_PACKET;
169 inst->copy_range = 0xffff; 174 inst->copy_range = 0xffff;
170 175
171 if (!try_module_get(THIS_MODULE))
172 goto out_free;
173
174 hlist_add_head(&inst->hlist, 176 hlist_add_head(&inst->hlist,
175 &instance_table[instance_hashfn(group_num)]); 177 &instance_table[instance_hashfn(group_num)]);
176 178
@@ -181,8 +183,6 @@ instance_create(u_int16_t group_num, int pid)
181 183
182 return inst; 184 return inst;
183 185
184out_free:
185 instance_put(inst);
186out_unlock: 186out_unlock:
187 write_unlock_bh(&instances_lock); 187 write_unlock_bh(&instances_lock);
188 return NULL; 188 return NULL;