Commit afe62c68 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

af_packet: lock imbalance

fanout_add() might return with fanout_mutex held.

Reduce indentation level while we are at it
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 68ac3191
...@@ -589,11 +589,14 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) ...@@ -589,11 +589,14 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
break; break;
} }
} }
err = -EINVAL;
if (match && match->defrag != defrag) if (match && match->defrag != defrag)
return -EINVAL; goto out;
if (!match) { if (!match) {
err = -ENOMEM;
match = kzalloc(sizeof(*match), GFP_KERNEL); match = kzalloc(sizeof(*match), GFP_KERNEL);
if (match) { if (!match)
goto out;
write_pnet(&match->net, sock_net(sk)); write_pnet(&match->net, sock_net(sk));
match->id = id; match->id = id;
match->type = type; match->type = type;
...@@ -609,9 +612,6 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) ...@@ -609,9 +612,6 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
dev_add_pack(&match->prot_hook); dev_add_pack(&match->prot_hook);
list_add(&match->list, &fanout_list); list_add(&match->list, &fanout_list);
} }
}
err = -ENOMEM;
if (match) {
err = -EINVAL; err = -EINVAL;
if (match->type == type && if (match->type == type &&
match->prot_hook.type == po->prot_hook.type && match->prot_hook.type == po->prot_hook.type &&
...@@ -625,7 +625,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags) ...@@ -625,7 +625,7 @@ static int fanout_add(struct sock *sk, u16 id, u16 type_flags)
err = 0; err = 0;
} }
} }
} out:
mutex_unlock(&fanout_mutex); mutex_unlock(&fanout_mutex);
return err; return err;
} }
......
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