Skip to content

Commit

Permalink
net/smc: postpone sk_refcnt increment in connect()
Browse files Browse the repository at this point in the history
[ Upstream commit 75c1edf ]

Same trigger condition as commit 8643474. 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: 8643474 ("net/smc: add fallback check to connect()")
Signed-off-by: liuyacan <liuyacan@corp.netease.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
liuyacan authored and gregkh committed Jun 9, 2022
1 parent 23a5767 commit 8eb0e5a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/smc/af_smc.c
Expand Up @@ -1283,9 +1283,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;
Expand Down

0 comments on commit 8eb0e5a

Please sign in to comment.