Commit 7f859721 authored by Ralf Bächle's avatar Ralf Bächle Committed by Thomas Graf

[AX25]: Fix ax25_get_socket locking

In an attempt to return a locked socket ax25_get_socket() was calling
lock_sock() with a spinlock held, bad idea.  Making matters worse it's
only user is running in bottom half context resulting in a potencial
attempt to sleep in bottom half context, so fix the locking there as well.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 400aee84
......@@ -180,8 +180,7 @@ struct sock *ax25_get_socket(ax25_address *my_addr, ax25_address *dest_addr,
!ax25cmp(&s->dest_addr, dest_addr) &&
s->sk->sk_type == type) {
sk = s->sk;
/* XXX Sleeps with spinlock held, use refcounts instead. XXX */
lock_sock(sk);
sock_hold(sk);
break;
}
}
......
......@@ -275,6 +275,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
/* Now find a suitable dgram socket */
sk = ax25_get_socket(&dest, &src, SOCK_DGRAM);
if (sk != NULL) {
bh_lock_sock(sk);
if (atomic_read(&sk->sk_rmem_alloc) >=
sk->sk_rcvbuf) {
kfree_skb(skb);
......@@ -286,7 +287,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
if (sock_queue_rcv_skb(sk, skb) != 0)
kfree_skb(skb);
}
release_sock(sk);
bh_unlock_sock(sk);
sock_put(sk);
} else {
kfree_skb(skb);
}
......
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