Skip to contentSkip to conversation

eth: gve: add missing netdev locks on reset and shutdown paths

PATCH Applied Jakub Kicinski 4 participants 4 messages Mar 28, 2025 – Apr 1, 2025

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 eth: gve: add missing netdev locks on reset and shutdown paths

All the misc entry points end up calling into either gve_open() or gve_close(), they take rtnl_lock today but since the recent instance locking changes should also take the instance lock.

Found by code inspection and untested.

Fixes cae03e5bdd9e ("net: hold netdev instance lock during queue operations")

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/net/ethernet/google/gve/gve_main.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/google/gve/gve_main.c +4 -0
index cb2f9978f45e..f9a73c956861 100644
@@ -2077,7 +2077,9 @@ static void gve_handle_reset(struct gve_priv *priv)
 
 	if (gve_get_do_reset(priv)) {
 		rtnl_lock();
+		netdev_lock(priv->dev);
 		gve_reset(priv, false);
+		netdev_unlock(priv->dev);
 		rtnl_unlock();
 	}
 }
@@ -2714,6 +2716,7 @@ static void gve_shutdown(struct pci_dev *pdev)
 	bool was_up = netif_running(priv->dev);
 
 	rtnl_lock();
+	netdev_lock(netdev);
 	if (was_up && gve_close(priv->dev)) {
 		/* If the dev was up, attempt to close, if close fails, reset */
 		gve_reset_and_teardown(priv, was_up);
@@ -2721,6 +2724,7 @@ static void gve_shutdown(struct pci_dev *pdev)
 		/* If the dev wasn't up or close worked, finish tearing down */
 		gve_teardown_priv_resources(priv);
 	}
+	netdev_unlock(netdev);
 	rtnl_unlock();
 }
 
Signature · 1 line
2.49.0
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Jakub Kicinski

All the misc entry points end up calling into either gve_open() or gve_close(), they take rtnl_lock today but since the recent instance locking changes should also take the instance lock.

Found by code inspection and untested.

Fixes cae03e5bdd9e ("net: hold netdev instance lock during queue operations")
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Jakub Kicinski
Quoted 9 lines · Jakub Kicinski

All the misc entry points end up calling into either gve_open() or gve_close(), they take rtnl_lock today but since the recent instance locking changes should also take the instance lock.

Found by code inspection and untested.

Fixes cae03e5bdd9e ("net: hold netdev instance lock during queue operations")
Quoted 45 lines

---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]

---
 drivers/net/ethernet/google/gve/gve_main.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/net/ethernet/google/gve/gve_main.c +4 -1
index cb2f9978f45e..f9a73c956861 100644
@@ -2077,7 +2077,9 @@ static void gve_handle_reset(struct gve_priv *priv)
 
        if (gve_get_do_reset(priv)) {
                rtnl_lock();
+               netdev_lock(priv->dev);
                gve_reset(priv, false);
+               netdev_unlock(priv->dev);
                rtnl_unlock();
        }
 }
@@ -2714,6 +2716,7 @@ static void gve_shutdown(struct pci_dev *pdev)
        bool was_up = netif_running(priv->dev);
 
        rtnl_lock();
+       netdev_lock(netdev);
        if (was_up && gve_close(priv->dev)) {
                /* If the dev was up, attempt to close, if close fails, reset */
                gve_reset_and_teardown(priv, was_up);
@@ -2721,6 +2724,7 @@ static void gve_shutdown(struct pci_dev *pdev)
                /* If the dev wasn't up or close worked, finish tearing down */
                gve_teardown_priv_resources(priv);
        }
+       netdev_unlock(netdev);
        rtnl_unlock();
 }
 
--

2.49.0

#3 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 28 Mar 2025 09:47:42 -0700 you wrote:

All the misc entry points end up calling into either gve_open() or gve_close(), they take rtnl_lock today but since the recent instance locking changes should also take the instance lock.

Found by code inspection and untested.

Fixes cae03e5bdd9e ("net: hold netdev instance lock during queue operations")

[...]

Here is the summary with links:
- [net] eth: gve: add missing netdev locks on reset and shutdown paths

    https://git.kernel.org/netdev/net/c/9e3267cf02c2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html