Skip to content

Commit

Permalink
net: Remove unnecessary variables
Browse files Browse the repository at this point in the history
It is not necessary to define variables to receive -ENOMEM,
directly return -ENOMEM.

Signed-off-by: zuoqilin <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>
  • Loading branch information
zuoqilin authored and klassert committed May 26, 2021
1 parent fe9f1d8 commit a925316
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions net/key/af_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,
struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);
struct sock *sk;
struct pfkey_sock *pfk;
int err;

if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EPERM;
Expand All @@ -150,10 +149,9 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,
if (protocol != PF_KEY_V2)
return -EPROTONOSUPPORT;

err = -ENOMEM;
sk = sk_alloc(net, PF_KEY, GFP_KERNEL, &key_proto, kern);
if (sk == NULL)
goto out;
return -ENOMEM;

pfk = pfkey_sk(sk);
mutex_init(&pfk->dump_lock);
Expand All @@ -169,8 +167,6 @@ static int pfkey_create(struct net *net, struct socket *sock, int protocol,
pfkey_insert(sk);

return 0;
out:
return err;
}

static int pfkey_release(struct socket *sock)
Expand Down

0 comments on commit a925316

Please sign in to comment.