From baab2ce7d2a8dbf6280ab09c011cfec1dd5972de Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Mon, 17 Dec 2007 22:41:21 -0800 Subject: [NETFILTER]: nfnetlink_{queue,log}: return proper error codes in instance_create Currently we return EINVAL for "instance exists", "allocation failed" and "module unloaded below us", which is completely inapproriate. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- net/netfilter/nfnetlink_log.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'net/netfilter/nfnetlink_log.c') diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index c12e1d1bd00e..ac58dc9d7247 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -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; } @@ -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); @@ -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; -- cgit v1.2.3