Skip to content

Commit 3a3db12

Browse files
Tony Lugregkh
authored andcommitted
net/smc: Keep smc_close_final rc during active close
commit 00e158f upstream. When smc_close_final() returns error, the return code overwrites by kernel_sock_shutdown() in smc_close_active(). The return code of smc_close_final() is more important than kernel_sock_shutdown(), and it will pass to userspace directly. Fix it by keeping both return codes, if smc_close_final() raises an error, return it or kernel_sock_shutdown()'s. Link: https://lore.kernel.org/linux-s390/[email protected]/ Fixes: 606a63c ("net/smc: Ensure the active closing peer first closes clcsock") Suggested-by: Karsten Graul <[email protected]> Signed-off-by: Tony Lu <[email protected]> Reviewed-by: Wen Gu <[email protected]> Acked-by: Karsten Graul <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b44a55e commit 3a3db12

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/smc/smc_close.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ int smc_close_active(struct smc_sock *smc)
195195
int old_state;
196196
long timeout;
197197
int rc = 0;
198+
int rc1 = 0;
198199

199200
timeout = current->flags & PF_EXITING ?
200201
0 : sock_flag(sk, SOCK_LINGER) ?
@@ -232,8 +233,11 @@ int smc_close_active(struct smc_sock *smc)
232233
/* actively shutdown clcsock before peer close it,
233234
* prevent peer from entering TIME_WAIT state.
234235
*/
235-
if (smc->clcsock && smc->clcsock->sk)
236-
rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
236+
if (smc->clcsock && smc->clcsock->sk) {
237+
rc1 = kernel_sock_shutdown(smc->clcsock,
238+
SHUT_RDWR);
239+
rc = rc ? rc : rc1;
240+
}
237241
} else {
238242
/* peer event has changed the state */
239243
goto again;

0 commit comments

Comments
 (0)