[Intel-wired-lan] [PATCH v5 net 4/7] i40e: avoid deadlock when calling unregister_netdev()
Mekala, SunithaX D
sunithax.d.mekala at intel.com
Tue Sep 8 06:19:24 UTC 2026
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces at osuosl.org> On Behalf Of Maciej Fijalkowski
> Sent: Wednesday, July 1, 2026 5:45 AM
> To: intel-wired-lan at lists.osuosl.org
> Cc: netdev at vger.kernel.org; Karlsson, Magnus <magnus.karlsson at intel.com>; kuba at kernel.org; pabeni at redhat.com; horms at kernel.org; Kitszel, Przemyslaw <przemyslaw.kitszel at intel.com>; Keller, Jacob E > <jacob.e.keller at intel.com>; Fijalkowski, Maciej <maciej.fijalkowski at intel.com>; Sashiko AI Review <sashiko-bot at kernel.org>
> Subject: [Intel-wired-lan] [PATCH v5 net 4/7] i40e: avoid deadlock when calling unregister_netdev()
>
> Sashiko reports:
> ***
> > +err_netdev:
> > if (vsi->netdev_registered) {
> > vsi->netdev_registered = false;
> > unregister_netdev(vsi->netdev);
> Could this result in a deadlock when called during a device rebuild?
> Looking at i40e_rebuild(), it explicitly acquires the RTNL lock before
> proceeding:
> drivers/net/ethernet/intel/i40e/i40e_main.c:i40e_rebuild() {
> ...
> if (!lock_acquired)
> rtnl_lock();
> ret = i40e_setup_pf_switch(pf, reinit, true);
> ...
> }
> If i40e_setup_pf_switch() calls i40e_vsi_reinit_setup() and takes this new
> err_netdev path, unregister_netdev() will unconditionally attempt to acquire
> rtnl_lock(), leading to a deadlock on the non-recursive mutex.
> ***
>
> Use unregister_netdevice() when the rebuild path already holds RTNL, and
> keep unregister_netdev() for callers that do not. This avoids both
> recursive RTNL locking and dropping RTNL in the middle of the VSI unwind
> path.
>
> Fixes: bc7d338fbb3f ("i40e: reinit flow for the main VSI")
> Reported-by: Sashiko AI Review <sashiko-bot at kernel.org>
> Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski at intel.com>
> ---
> drivers/net/ethernet/intel/i40e/i40e_main.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
Tested-by: Sunitha Mekala <sunithax.d.mekala at intel.com> (A Contingent worker at Intel)
More information about the Intel-wired-lan
mailing list