Commit 9b1e918a authored by Michał Mirosław's avatar MichaÅ� MirosÅ�aw Committed by Greg Kroah-Hartman

Fix reference counting (memory leak) problem in __nfulnl_send() and callers...

Fix reference counting (memory leak) problem in __nfulnl_send() and callers related to packet queueing.
Signed-off-by: default avatarMichał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9e44f708
...@@ -217,6 +217,11 @@ _instance_destroy2(struct nfulnl_instance *inst, int lock) ...@@ -217,6 +217,11 @@ _instance_destroy2(struct nfulnl_instance *inst, int lock)
spin_lock_bh(&inst->lock); spin_lock_bh(&inst->lock);
if (inst->skb) { if (inst->skb) {
/* timer "holds" one reference (we have one more) */
if (timer_pending(&inst->timer)) {
del_timer(&inst->timer);
instance_put(inst);
}
if (inst->qlen) if (inst->qlen)
__nfulnl_send(inst); __nfulnl_send(inst);
if (inst->skb) { if (inst->skb) {
...@@ -363,9 +368,6 @@ __nfulnl_send(struct nfulnl_instance *inst) ...@@ -363,9 +368,6 @@ __nfulnl_send(struct nfulnl_instance *inst)
{ {
int status; int status;
if (timer_pending(&inst->timer))
del_timer(&inst->timer);
if (!inst->skb) if (!inst->skb)
return 0; return 0;
...@@ -392,6 +394,8 @@ static void nfulnl_timer(unsigned long data) ...@@ -392,6 +394,8 @@ static void nfulnl_timer(unsigned long data)
UDEBUG("timer function called, flushing buffer\n"); UDEBUG("timer function called, flushing buffer\n");
spin_lock_bh(&inst->lock); spin_lock_bh(&inst->lock);
if (timer_pending(&inst->timer)) /* is it always true or false here? */
del_timer(&inst->timer);
__nfulnl_send(inst); __nfulnl_send(inst);
instance_put(inst); instance_put(inst);
spin_unlock_bh(&inst->lock); spin_unlock_bh(&inst->lock);
...@@ -689,6 +693,11 @@ nfulnl_log_packet(unsigned int pf, ...@@ -689,6 +693,11 @@ nfulnl_log_packet(unsigned int pf,
* enough room in the skb left. flush to userspace. */ * enough room in the skb left. flush to userspace. */
UDEBUG("flushing old skb\n"); UDEBUG("flushing old skb\n");
/* timer "holds" one reference (we have another one) */
if (timer_pending(&inst->timer)) {
del_timer(&inst->timer);
instance_put(inst);
}
__nfulnl_send(inst); __nfulnl_send(inst);
if (!(inst->skb = nfulnl_alloc_skb(nlbufsiz, size))) { if (!(inst->skb = nfulnl_alloc_skb(nlbufsiz, size))) {
......
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