net/smc: Fix cleanup when register ULP fails
authorTony Lu <tonylu@linux.alibaba.com>
Fri, 25 Feb 2022 06:56:57 +0000 (14:56 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Feb 2022 11:31:49 +0000 (11:31 +0000)
This patch calls smc_ib_unregister_client() when tcp_register_ulp()
fails, and make sure to clean it up.

Fixes: d7cd421da9da ("net/smc: Introduce TCP ULP support")
Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/smc/af_smc.c

index 81984c1c0e78aa6f7f55d7e2433b94eba23c77e1..284befa909676b8881a443b37442980700d26d34 100644 (file)
@@ -3087,12 +3087,14 @@ static int __init smc_init(void)
        rc = tcp_register_ulp(&smc_ulp_ops);
        if (rc) {
                pr_err("%s: tcp_ulp_register fails with %d\n", __func__, rc);
-               goto out_sock;
+               goto out_ib;
        }
 
        static_branch_enable(&tcp_have_smc);
        return 0;
 
+out_ib:
+       smc_ib_unregister_client();
 out_sock:
        sock_unregister(PF_SMC);
 out_proto6: