Skip to contentSkip to conversation

alx: acquire mutex for alx_reinit in alx_change_mtu

PATCH Superseded Niels Dossche 2 participants 4 messages Mar 10, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alx: acquire mutex for alx_reinit in alx_change_mtu

alx_reinit has a lockdep assertion that the alx->mtx mutex must be held. alx_reinit is called from two places: alx_reset and alx_change_mtu. alx_reset does acquire alx->mtx before calling alx_reinit. alx_change_mtu does not acquire this mutex, nor do its callers or any path towards alx_change_mtu.
Acquire the mutex in alx_change_mtu.

---
 drivers/net/ethernet/atheros/alx/main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/atheros/alx/main.c +4 -1
index 4ad3fc72e74e..a89b93cb4e26 100644
@@ -1181,8 +1181,11 @@ static int alx_change_mtu(struct net_device *netdev, int mtu)
 	alx->hw.mtu = mtu;
 	alx->rxbuf_size = max(max_frame, ALX_DEF_RXBUF_SIZE);
 	netdev_update_features(netdev);
-	if (netif_running(netdev))
+	if (netif_running(netdev)) {
+		mutex_lock(&alx->mtx);
 		alx_reinit(alx);
+		mutex_unlock(&alx->mtx);
+	}
 	return 0;
 }
 
Signature · 1 line
2.35.1
maintainer
#1 lore raw
Quoted 8 lines · On Thu, 10 Mar 2022 17:13:16 +0100 Niels Dossche wrote:

alx_reinit has a lockdep assertion that the alx->mtx mutex must be held. alx_reinit is called from two places: alx_reset and alx_change_mtu. alx_reset does acquire alx->mtx before calling alx_reinit. alx_change_mtu does not acquire this mutex, nor do its callers or any path towards alx_change_mtu.
Acquire the mutex in alx_change_mtu.

What's the Fixes tag?

#2 lore raw
Quoted 11 lines · Jakub Kicinski
Quoted 8 lines · On Thu, 10 Mar 2022 17:13:16 +0100 Niels Dossche wrote:

alx_reinit has a lockdep assertion that the alx->mtx mutex must be held. alx_reinit is called from two places: alx_reset and alx_change_mtu. alx_reset does acquire alx->mtx before calling alx_reinit. alx_change_mtu does not acquire this mutex, nor do its callers or any path towards alx_change_mtu.
Acquire the mutex in alx_change_mtu.

What's the Fixes tag?

Commit 4a5fe57e7751 ("alx: use fine-grained locking instead of RTNL") introduced fine-grained locking and introduced the assertion. I can resend the patch with the Fixes tag if you want me to.

maintainer
#3 lore raw
Quoted 9 lines · On Fri, 11 Mar 2022 00:14:55 +0100 Niels Dossche wrote:
Quoted 8 lines · Jakub Kicinski
Quoted 7 lines · On Thu, 10 Mar 2022 17:13:16 +0100 Niels Dossche wrote:

alx_reinit has a lockdep assertion that the alx->mtx mutex must be held. alx_reinit is called from two places: alx_reset and alx_change_mtu. alx_reset does acquire alx->mtx before calling alx_reinit. alx_change_mtu does not acquire this mutex, nor do its callers or any path towards alx_change_mtu.
Acquire the mutex in alx_change_mtu.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

What's the Fixes tag?

Commit 4a5fe57e7751 ("alx: use fine-grained locking instead of RTNL") introduced fine-grained locking and introduced the assertion. I can resend the patch with the Fixes tag if you want me to.

If you don't mind resend would be helpful, thanks!