OSDN Git Service

net: sfp: move rtnl lock to cover reading state
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Wed, 17 May 2023 10:37:52 +0000 (11:37 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 19 May 2023 02:52:31 +0000 (19:52 -0700)
As preparation to moving st_mutex inside rtnl_lock, we need to first
move the rtnl lock to cover reading the state.

Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/sfp.c

index c97a873..3fc703e 100644 (file)
@@ -2601,6 +2601,7 @@ static void sfp_check_state(struct sfp *sfp)
        unsigned int state, i, changed;
 
        mutex_lock(&sfp->st_mutex);
+       rtnl_lock();
        state = sfp_get_state(sfp);
        changed = state ^ sfp->state;
        if (sfp->tx_fault_ignore)
@@ -2616,7 +2617,6 @@ static void sfp_check_state(struct sfp *sfp)
        state |= sfp->state & (SFP_F_TX_DISABLE | SFP_F_RATE_SELECT);
        sfp->state = state;
 
-       rtnl_lock();
        if (changed & SFP_F_PRESENT)
                sfp_sm_event(sfp, state & SFP_F_PRESENT ?
                                SFP_E_INSERT : SFP_E_REMOVE);