Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: fix sock compilation error under CONFIG_PREEMPT_RT

When CONFIG_PREEMPT_RT is enabled, __SPIN_LOCK_UNLOCKED() expands to a
brace-enclosed initializer rather than a compound literal, which cannot
be used in assignment expressions. This causes a build failure:

net/core/sock.c:3787:29: error: expected expression before '{' token
3787 | tmp.slock = __SPIN_LOCK_UNLOCKED(tmp.slock);

Use declaration-with-initializer instead of assignment, consistent with
how __SPIN_LOCK_UNLOCKED() is used elsewhere in the kernel (e.g.
DEFINE_SPINLOCK).

Fixes: 5151ec54f586 ("net: use try_cmpxchg() in lock_sock_nested()")
Suggested-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jiayuan Chen <jiayuan.chen@shopee.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260228111319.79506-1-jiayuan.chen@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Jiayuan Chen and committed by
Jakub Kicinski
58e443b7 1e08faf9

+8 -5
+8 -5
net/core/sock.c
··· 3782 3782 might_sleep(); 3783 3783 #ifdef CONFIG_64BIT 3784 3784 if (sizeof(struct slock_owned) == sizeof(long)) { 3785 - socket_lock_t tmp, old; 3785 + socket_lock_t tmp = { 3786 + .slock = __SPIN_LOCK_UNLOCKED(tmp.slock), 3787 + .owned = 1, 3788 + }; 3789 + socket_lock_t old = { 3790 + .slock = __SPIN_LOCK_UNLOCKED(old.slock), 3791 + .owned = 0, 3792 + }; 3786 3793 3787 - tmp.slock = __SPIN_LOCK_UNLOCKED(tmp.slock); 3788 - tmp.owned = 1; 3789 - old.slock = __SPIN_LOCK_UNLOCKED(old.slock); 3790 - old.owned = 0; 3791 3794 if (likely(try_cmpxchg(&sk->sk_lock.combined, 3792 3795 &old.combined, tmp.combined))) 3793 3796 return;