Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 78545
b: refs/heads/master
c: baab2ce
h: refs/heads/master
i:
  78543: ee59e28
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Jan 28, 2008
1 parent 33fa740 commit 415bf24
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 1792bab4caaa85bae858799bb6231f171f59b58a
refs/heads/master: baab2ce7d2a8dbf6280ab09c011cfec1dd5972de
14 changes: 9 additions & 5 deletions trunk/net/netfilter/nfnetlink_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,23 @@ static struct nfulnl_instance *
instance_create(u_int16_t group_num, int pid)
{
struct nfulnl_instance *inst;
int err;

write_lock_bh(&instances_lock);
if (__instance_lookup(group_num)) {
inst = NULL;
err = -EEXIST;
goto out_unlock;
}

inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
if (!inst)
if (!inst) {
err = -ENOMEM;
goto out_unlock;
}

if (!try_module_get(THIS_MODULE)) {
kfree(inst);
err = -EAGAIN;
goto out_unlock;
}

Expand Down Expand Up @@ -169,7 +173,7 @@ instance_create(u_int16_t group_num, int pid)

out_unlock:
write_unlock_bh(&instances_lock);
return NULL;
return ERR_PTR(err);
}

static void __nfulnl_flush(struct nfulnl_instance *inst);
Expand Down Expand Up @@ -731,8 +735,8 @@ nfulnl_recv_config(struct sock *ctnl, struct sk_buff *skb,

inst = instance_create(group_num,
NETLINK_CB(skb).pid);
if (!inst) {
ret = -EINVAL;
if (IS_ERR(inst)) {
ret = PTR_ERR(inst);
goto out;
}
break;
Expand Down
21 changes: 14 additions & 7 deletions trunk/net/netfilter/nfnetlink_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,21 @@ instance_lookup(u_int16_t queue_num)
static struct nfqnl_instance *
instance_create(u_int16_t queue_num, int pid)
{
struct nfqnl_instance *inst = NULL;
struct nfqnl_instance *inst;
unsigned int h;
int err;

spin_lock(&instances_lock);
if (instance_lookup(queue_num))
if (instance_lookup(queue_num)) {
err = -EEXIST;
goto out_unlock;
}

inst = kzalloc(sizeof(*inst), GFP_ATOMIC);
if (!inst)
if (!inst) {
err = -ENOMEM;
goto out_unlock;
}

inst->queue_num = queue_num;
inst->peer_pid = pid;
Expand All @@ -109,8 +114,10 @@ instance_create(u_int16_t queue_num, int pid)
INIT_LIST_HEAD(&inst->queue_list);
INIT_RCU_HEAD(&inst->rcu);

if (!try_module_get(THIS_MODULE))
if (!try_module_get(THIS_MODULE)) {
err = -EAGAIN;
goto out_free;
}

h = instance_hashfn(queue_num);
hlist_add_head_rcu(&inst->hlist, &instance_table[h]);
Expand All @@ -123,7 +130,7 @@ instance_create(u_int16_t queue_num, int pid)
kfree(inst);
out_unlock:
spin_unlock(&instances_lock);
return NULL;
return ERR_PTR(err);
}

static void nfqnl_flush(struct nfqnl_instance *queue, nfqnl_cmpfn cmpfn,
Expand Down Expand Up @@ -724,8 +731,8 @@ nfqnl_recv_config(struct sock *ctnl, struct sk_buff *skb,
goto err_out_unlock;
}
queue = instance_create(queue_num, NETLINK_CB(skb).pid);
if (!queue) {
ret = -EINVAL;
if (IS_ERR(queue)) {
ret = PTR_ERR(queue);
goto err_out_unlock;
}
break;
Expand Down

0 comments on commit 415bf24

Please sign in to comment.