Message ID | 20241202-netpoll_rcu_herbet_fix-v2-1-2b9d58edc76a@debian.org (mailing list archive) |
---|---|
State | Accepted |
Commit | a9ab02ed97c654a9ea09afb3e6294cea3768c388 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [RESEND,net-next,v2] netpoll: Use rtnl_dereference() for npinfo pointer access | expand |
Hello: This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Mon, 02 Dec 2024 16:22:05 -0800 you wrote: > In the __netpoll_setup() function, when accessing the device's npinfo > pointer, replace rcu_access_pointer() with rtnl_dereference(). This > change is more appropriate, as suggested by Herbert Xu[1]. > > The function is called with the RTNL mutex held, and the pointer is > being dereferenced later, so, dereference earlier and just reuse the > pointer for the if/else. > > [...] Here is the summary with links: - [RESEND,net-next,v2] netpoll: Use rtnl_dereference() for npinfo pointer access https://git.kernel.org/netdev/net-next/c/a9ab02ed97c6 You are awesome, thank you!
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 2e459b9d88eb52b7c5e4710bf3f7740045d9314b..99e5aa9cc992f429eecf20aeadd04dc293b8f22b 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -634,7 +634,8 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev) goto out; } - if (!rcu_access_pointer(ndev->npinfo)) { + npinfo = rtnl_dereference(ndev->npinfo); + if (!npinfo) { npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL); if (!npinfo) { err = -ENOMEM; @@ -654,7 +655,6 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev) goto free_npinfo; } } else { - npinfo = rtnl_dereference(ndev->npinfo); refcount_inc(&npinfo->refcnt); }