Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60546c0b authored by liuyacan's avatar liuyacan Committed by Greg Kroah-Hartman
Browse files

net/smc: postpone sk_refcnt increment in connect()



[ Upstream commit 75c1edf23b95a9c66923d9269d8e86e4dbde151f ]

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: default avatarliuyacan <liuyacan@corp.netease.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 91121ee5
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -877,9 +877,9 @@ static int smc_connect(struct socket *sock, struct sockaddr *addr,
	if (rc && rc != -EINPROGRESS)
	if (rc && rc != -EINPROGRESS)
		goto out;
		goto out;


	sock_hold(&smc->sk); /* sock put in passive closing */
	if (smc->use_fallback)
	if (smc->use_fallback)
		goto out;
		goto out;
	sock_hold(&smc->sk); /* sock put in passive closing */
	if (flags & O_NONBLOCK) {
	if (flags & O_NONBLOCK) {
		if (schedule_work(&smc->connect_work))
		if (schedule_work(&smc->connect_work))
			smc->connect_nonblock = 1;
			smc->connect_nonblock = 1;