bareudp: Use rtnl_dereference() in bareudp_sock_release().

kernel test robot reported sparse warning in bareudp_sock_release():

  drivers/net/bareudp.c:288:12: warning: incorrect type in assignment (different address spaces)
  drivers/net/bareudp.c:288:12:    expected struct sock *sk
  drivers/net/bareudp.c:288:12:    got struct sock [noderef] __rcu *sk

The warning is not new and exists since the initial bareudp commit
571912c69f ("net: UDP tunnel encapsulation module for tunnelling
different protocols like MPLS, IP, NSH etc.").

Let's use rtnl_dereference().

Note that bareudp_sock_release() is called from bareudp_stop()
under RTNL, so there is no real issue even without the helper.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605062359.e3gOfZCr-lkp@intel.com/
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260518050726.318824-6-kuniyu@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Kuniyuki Iwashima
2026-05-18 05:07:12 +00:00
committed by Jakub Kicinski
parent d38be92172
commit e6409584de

View File

@@ -285,7 +285,7 @@ static void bareudp_sock_release(struct bareudp_dev *bareudp)
{
struct sock *sk;
sk = bareudp->sk;
sk = rtnl_dereference(bareudp->sk);
rcu_assign_pointer(bareudp->sk, NULL);
udp_tunnel_sock_release(sk);
}