Skip to contentSkip to conversation

net/smc: fixes 2019-06-26

PATCH In review Ursula Braun 2 participants 4 messages Jun 26, 2019

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover net/smc: fixes 2019-06-26

Dave,

here are 2 small smc fixes for the net tree.

Thanks, Ursula

Huaping Zhou (1):
net/smc: hold conns_lock before calling smc_lgr_register_conn()

YueHaibing (1):
net/smc: Fix error path in smc_init

 net/smc/af_smc.c   | 5 ++++-
 net/smc/smc_core.c | 3 +++
 2 files changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/2 net/smc: hold conns_lock before calling smc_lgr_register_conn()

From: Huaping Zhou <[email protected]>

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.

---
 net/smc/smc_core.c | 3 +++
 1 file changed, 3 insertions(+)
net/smc/smc_core.c +3 -0
index 2d2850adc2a3..4ca50ddf8d16 100644
@@ -652,7 +652,10 @@ int smc_conn_create(struct smc_sock *smc, struct smc_init_info *ini)
 		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;
Signature · 1 line
2.17.1
#2 lore raw

PATCH 2/2 net/smc: Fix error path in smc_init

In reply to Ursula Braun

From: YueHaibing <[email protected]>

If register_pernet_subsys success in smc_init,
we should cleanup it in case any other error.

Fixes 64e28b52c7a6 (net/smc: add pnet table namespace support")
---
 net/smc/af_smc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/smc/af_smc.c +4 -1
index 0c874e996f85..7621ec2f539c 100644
@@ -2029,7 +2029,7 @@ static int __init smc_init(void)
 
 	rc = smc_pnet_init();
 	if (rc)
-		return rc;
+		goto out_pernet_subsys;
 
 	rc = smc_llc_init();
 	if (rc) {
@@ -2080,6 +2080,9 @@ static int __init smc_init(void)
 	proto_unregister(&smc_proto);
 out_pnet:
 	smc_pnet_exit();
+out_pernet_subsys:
+	unregister_pernet_subsys(&smc_net_ops);
+
 	return rc;
 }
 
Signature · 1 line
2.17.1