Skip to content

Commit

Permalink
phonet: take correct lock to peek at the RX queue
Browse files Browse the repository at this point in the history
The receive queue is protected by its embedded spin-lock, not the
socket lock, so we need the former lock here (and only that one).

Fixes: 107d0d9 ("Phonet: Phonet datagram transport protocol")
Reported-by: Luosili <rootlab@huawei.com>
Signed-off-by: Rémi Denis-Courmont <courmisch@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20240218081214.4806-1-remi@remlab.net
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
  • Loading branch information
Rémi Denis-Courmont authored and Paolo Abeni committed Feb 22, 2024
1 parent 603ead9 commit 3b2d9bc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/phonet/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ static int pn_ioctl(struct sock *sk, int cmd, int *karg)

switch (cmd) {
case SIOCINQ:
lock_sock(sk);
spin_lock_bh(&sk->sk_receive_queue.lock);
skb = skb_peek(&sk->sk_receive_queue);
*karg = skb ? skb->len : 0;
release_sock(sk);
spin_unlock_bh(&sk->sk_receive_queue.lock);
return 0;

case SIOCPNADDRESOURCE:
Expand Down

0 comments on commit 3b2d9bc

Please sign in to comment.