diff options
| author | Kuniyuki Iwashima <[email protected]> | 2024-09-05 19:32:37 +0000 |
|---|---|---|
| committer | Jakub Kicinski <[email protected]> | 2024-09-10 00:14:26 +0000 |
| commit | 579770dd89855915096db8364261543c37ed34ef (patch) | |
| tree | c88cbcdd2d0a6e37fe212c8b5c6fa84aa0d44a53 /net/unix/af_unix.c | |
| parent | Merge tag 'linux-can-next-for-6.12-20240909' of git://git.kernel.org/pub/scm/... (diff) | |
| download | kernel-579770dd89855915096db8364261543c37ed34ef.tar.gz kernel-579770dd89855915096db8364261543c37ed34ef.zip | |
af_unix: Remove single nest in manage_oob().
This is a prep for the later fix.
No functional change intended.
Signed-off-by: Kuniyuki Iwashima <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'net/unix/af_unix.c')
| -rw-r--r-- | net/unix/af_unix.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index a1894019ebd5..03820454bc72 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -2654,11 +2654,10 @@ static int unix_stream_recv_urg(struct unix_stream_read_state *state) static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk, int flags, int copied) { + struct sk_buff *unlinked_skb = NULL; struct unix_sock *u = unix_sk(sk); if (!unix_skb_len(skb)) { - struct sk_buff *unlinked_skb = NULL; - spin_lock(&sk->sk_receive_queue.lock); if (copied && (!u->oob_skb || skb == u->oob_skb)) { @@ -2674,31 +2673,33 @@ static struct sk_buff *manage_oob(struct sk_buff *skb, struct sock *sk, spin_unlock(&sk->sk_receive_queue.lock); consume_skb(unlinked_skb); - } else { - struct sk_buff *unlinked_skb = NULL; + return skb; + } - spin_lock(&sk->sk_receive_queue.lock); + spin_lock(&sk->sk_receive_queue.lock); - if (skb == u->oob_skb) { - if (copied) { - skb = NULL; - } else if (!(flags & MSG_PEEK)) { - WRITE_ONCE(u->oob_skb, NULL); + if (skb != u->oob_skb) + goto unlock; - if (!sock_flag(sk, SOCK_URGINLINE)) { - __skb_unlink(skb, &sk->sk_receive_queue); - unlinked_skb = skb; - skb = skb_peek(&sk->sk_receive_queue); - } - } else if (!sock_flag(sk, SOCK_URGINLINE)) { - skb = skb_peek_next(skb, &sk->sk_receive_queue); - } + if (copied) { + skb = NULL; + } else if (!(flags & MSG_PEEK)) { + WRITE_ONCE(u->oob_skb, NULL); + + if (!sock_flag(sk, SOCK_URGINLINE)) { + __skb_unlink(skb, &sk->sk_receive_queue); + unlinked_skb = skb; + skb = skb_peek(&sk->sk_receive_queue); } + } else if (!sock_flag(sk, SOCK_URGINLINE)) { + skb = skb_peek_next(skb, &sk->sk_receive_queue); + } - spin_unlock(&sk->sk_receive_queue.lock); +unlock: + spin_unlock(&sk->sk_receive_queue.lock); + + kfree_skb(unlinked_skb); - kfree_skb(unlinked_skb); - } return skb; } #endif |
