net/smc: hold conns_lock before calling smc_lgr_register_conn()
authorHuaping Zhou <zhp@smail.nju.edu.cn>
Wed, 26 Jun 2019 15:47:49 +0000 (17:47 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 26 Jun 2019 17:10:16 +0000 (10:10 -0700)
After smc_lgr_create(), the newly created link group is added
to smc_lgr_list, thus is accessible from other context.
Although link group creation is serialized by
smc_create_lgr_pending, the new link group may still be accessed
concurrently. For example, if ib_device is no longer active,
smc_ib_port_event_work() will call smc_port_terminate(), which
in turn will call __smc_lgr_terminate() on every link group of
this device. So conns_lock is required here.

Signed-off-by: Huaping Zhou <zhp@smail.nju.edu.cn>
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/smc_core.c

index 2d2850adc2a3fa7a6a8667d79add5678beb130ca..4ca50ddf8d1619a78e8a119ef2701d69957a8cd9 100644 (file)
@@ -652,7 +652,10 @@ create:
                rc = smc_lgr_create(smc, ini);
                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;