net/smc: Don't call clcsock shutdown twice when smc shutdown
authorTony Lu <tonylu@linux.alibaba.com>
Fri, 26 Nov 2021 02:41:35 +0000 (10:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Dec 2021 08:04:53 +0000 (09:04 +0100)
commit724c50cac0d5063ab514fd7ea41e57ba4e093d10
tree6c0b74c29b2bb7d1e1af7ab653884d06c0f969b0
parentf7fc72a508cf115c273a7a29350069def1041890
net/smc: Don't call clcsock shutdown twice when smc shutdown

[ Upstream commit bacb6c1e47691cda4a95056c21b5487fb7199fcc ]

When applications call shutdown() with SHUT_RDWR in userspace,
smc_close_active() calls kernel_sock_shutdown(), and it is called
twice in smc_shutdown().

This fixes this by checking sk_state before do clcsock shutdown, and
avoids missing the application's call of smc_shutdown().

Link: https://lore.kernel.org/linux-s390/1f67548e-cbf6-0dce-82b5-10288a4583bd@linux.ibm.com/
Fixes: 606a63c9783a ("net/smc: Ensure the active closing peer first closes clcsock")
Signed-off-by: Tony Lu <tonylu@linux.alibaba.com>
Reviewed-by: Wen Gu <guwen@linux.alibaba.com>
Acked-by: Karsten Graul <kgraul@linux.ibm.com>
Link: https://lore.kernel.org/r/20211126024134.45693-1-tonylu@linux.alibaba.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/smc/af_smc.c