Skip to content

Commit 301428e

Browse files
Ursula Braundavem330
authored andcommitted
net/smc: fix refcounting for non-blocking connect()
If a nonblocking socket is immediately closed after connect(), the connect worker may not have started. This results in a refcount problem, since sock_hold() is called from the connect worker. This patch moves the sock_hold in front of the connect worker scheduling. Reported-by: [email protected] Fixes: 50717a3 ("net/smc: nonblocking connect rework") Reviewed-by: Karsten Graul <[email protected]> Signed-off-by: Ursula Braun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ad9bd8d commit 301428e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/smc/af_smc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,6 @@ static int __smc_connect(struct smc_sock *smc)
707707
int smc_type;
708708
int rc = 0;
709709

710-
sock_hold(&smc->sk); /* sock put in passive closing */
711-
712710
if (smc->use_fallback)
713711
return smc_connect_fallback(smc, smc->fallback_rsn);
714712

@@ -853,6 +851,8 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,
853851
rc = kernel_connect(smc->clcsock, addr, alen, flags);
854852
if (rc && rc != -EINPROGRESS)
855853
goto out;
854+
855+
sock_hold(&smc->sk); /* sock put in passive closing */
856856
if (flags & O_NONBLOCK) {
857857
if (schedule_work(&smc->connect_work))
858858
smc->connect_nonblock = 1;

0 commit comments

Comments
 (0)