From: liuyacan Date: Mon, 23 May 2022 04:57:07 +0000 (+0800) Subject: net/smc: postpone sk_refcnt increment in connect() X-Git-Tag: howlett/maple/20220722_2~368^2~10^2~3 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=75c1edf23b95a9c66923d9269d8e86e4dbde151f;p=users%2Fjedix%2Flinux-maple.git net/smc: postpone sk_refcnt increment in connect() Same trigger condition as commit 86434744. When setsockopt runs in parallel to a connect(), and switch the socket into fallback mode. Then the sk_refcnt is incremented in smc_connect(), but its state stay in SMC_INIT (NOT SMC_ACTIVE). This cause the corresponding sk_refcnt decrement in __smc_release() will not be performed. Fixes: 86434744fedf ("net/smc: add fallback check to connect()") Signed-off-by: liuyacan Signed-off-by: David S. Miller --- diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index fce16b9d6e1a..45a24d24210f 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1564,9 +1564,9 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr, if (rc && rc != -EINPROGRESS) goto out; - sock_hold(&smc->sk); /* sock put in passive closing */ if (smc->use_fallback) goto out; + sock_hold(&smc->sk); /* sock put in passive closing */ if (flags & O_NONBLOCK) { if (queue_work(smc_hs_wq, &smc->connect_work)) smc->connect_nonblock = 1;