net/smc: postpone sk_refcnt increment in connect()
authorliuyacan <liuyacan@corp.netease.com>
Mon, 23 May 2022 04:57:07 +0000 (12:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:23:03 +0000 (10:23 +0200)
commit8eb0e5a2659cf7793b675173cbdf9f6ea2be458f
treeacf5d4d7c15170ed989c555366575841b5dd3c46
parent23a5767183453bc46b81061ffad3b34435c3068b
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: liuyacan <liuyacan@corp.netease.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/smc/af_smc.c