Commit 28f715b9 authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: nf_queue: prefer nf_queue_entry_free

Instead of dropping refs+kfree, use the helper added in previous patch.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent af370ab3
...@@ -155,18 +155,16 @@ static void nf_ip6_saveroute(const struct sk_buff *skb, ...@@ -155,18 +155,16 @@ static void nf_ip6_saveroute(const struct sk_buff *skb,
static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
unsigned int index, unsigned int queuenum) unsigned int index, unsigned int queuenum)
{ {
int status = -ENOENT;
struct nf_queue_entry *entry = NULL; struct nf_queue_entry *entry = NULL;
const struct nf_queue_handler *qh; const struct nf_queue_handler *qh;
struct net *net = state->net; struct net *net = state->net;
unsigned int route_key_size; unsigned int route_key_size;
int status;
/* QUEUE == DROP if no one is waiting, to be safe. */ /* QUEUE == DROP if no one is waiting, to be safe. */
qh = rcu_dereference(net->nf.queue_handler); qh = rcu_dereference(net->nf.queue_handler);
if (!qh) { if (!qh)
status = -ESRCH; return -ESRCH;
goto err;
}
switch (state->pf) { switch (state->pf) {
case AF_INET: case AF_INET:
...@@ -181,14 +179,12 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, ...@@ -181,14 +179,12 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
} }
entry = kmalloc(sizeof(*entry) + route_key_size, GFP_ATOMIC); entry = kmalloc(sizeof(*entry) + route_key_size, GFP_ATOMIC);
if (!entry) { if (!entry)
status = -ENOMEM; return -ENOMEM;
goto err;
}
if (skb_dst(skb) && !skb_dst_force(skb)) { if (skb_dst(skb) && !skb_dst_force(skb)) {
status = -ENETDOWN; kfree(entry);
goto err; return -ENETDOWN;
} }
*entry = (struct nf_queue_entry) { *entry = (struct nf_queue_entry) {
...@@ -212,17 +208,12 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state, ...@@ -212,17 +208,12 @@ static int __nf_queue(struct sk_buff *skb, const struct nf_hook_state *state,
} }
status = qh->outfn(entry, queuenum); status = qh->outfn(entry, queuenum);
if (status < 0) { if (status < 0) {
nf_queue_entry_release_refs(entry); nf_queue_entry_free(entry);
goto err; return status;
} }
return 0; return 0;
err:
kfree(entry);
return status;
} }
/* Packets leaving via this function must come back through nf_reinject(). */ /* Packets leaving via this function must come back through nf_reinject(). */
......
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