diff mbox series

alx: acquire mutex for alx_reinit in alx_change_mtu

Message ID 20220310161313.43595-1-dossche.niels@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series alx: acquire mutex for alx_reinit in alx_change_mtu | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 7 this patch: 7
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 7 this patch: 7
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 12 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Niels Dossche March 10, 2022, 4:13 p.m. UTC
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.

Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---
 drivers/net/ethernet/atheros/alx/main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski March 10, 2022, 11:05 p.m. UTC | #1
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.
> 
> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>

What's the Fixes tag?
Niels Dossche March 10, 2022, 11:14 p.m. UTC | #2
On 11/03/2022 00:05, Jakub Kicinski wrote:
> 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.
>>
>> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
> 
> 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.
Jakub Kicinski March 10, 2022, 11:20 p.m. UTC | #3
On Fri, 11 Mar 2022 00:14:55 +0100 Niels Dossche wrote:
> On 11/03/2022 00:05, Jakub Kicinski wrote:
> > 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.
> >>
> >> Signed-off-by: Niels Dossche <dossche.niels@gmail.com>  
> > 
> > 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!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 4ad3fc72e74e..a89b93cb4e26 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -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;
 }