net/smc: hold conns_lock before calling smc_lgr_register_conn()
Quoted 9 lines · Huaping Zhou
After
smc_lgr_create(), the newly created link group is added tosmc_lgr_list, thus is accessible from other context. Although link group creation is serialized bysmc_create_lgr_pending, the new link group may still be accessed concurrently. For example, ifib_deviceis no longer active,smc_ib_port_event_work()will callsmc_port_terminate(), which in turn will call__smc_lgr_terminate()on every link group of this device. Soconns_lockis required here.
Thanks, looks good. Your patch will be part of our next patch submission for the net-tree.
Regards, Ursula
Quoted 21 lines
Signed-off-by Huaping Zhou <[email protected]>--- net/smc/smc_core.c | 3 +++ 1 file changed, 3 insertions(+)net/smc/smc_core.c +3
-0@@ -653,7 +653,10 @@ int smc_conn_create(struct smc_sock *smc, bool is_smcd, int srv_first_contact, lcl->id_for_peer, vlan_id, smcd, peer_gid);if (rc) goto out; + lgr = conn->lgr; +write_lock_bh (&lgr->conns_lock);smc_lgr_register_conn (conn);/* add smc conn to lgr */ +write_unlock_bh (&lgr->conns_lock); } conn->local_tx_ctrl.common.type =SMC_CDC_MSG_TYPE ; conn->local_tx_ctrl.len =SMC_WR_TX_SIZE ;