summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUrsula Braun <ubraun@linux.ibm.com>2019-10-23 09:44:05 -0400
committerDavid S. Miller <davem@davemloft.net>2019-10-25 22:18:21 -0400
commitf536dffc0b79738c3104af999318279dccbaa261 (patch)
tree7fbe29b9602d336c4451a8b5bcc5f20686afb393
parent91e2e57636f163837e1aea2ce6c4995b8a2a6f10 (diff)
net/smc: fix closing of fallback SMC sockets
For SMC sockets forced to fallback to TCP, the file is propagated from the outer SMC to the internal TCP socket. When closing the SMC socket, the internal TCP socket file pointer must be restored to the original NULL value, otherwise memory leaks may show up (found with CONFIG_DEBUG_KMEMLEAK). The internal TCP socket is released in smc_clcsock_release(), which calls __sock_release() function in net/socket.c. This calls the needed iput(SOCK_INODE(sock)) only, if the file pointer has been reset to the original NULL-value. Fixes: 07603b230895 ("net/smc: propagate file from SMC to TCP socket") Signed-off-by: Ursula Braun <ubraun@linux.ibm.com> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/smc/af_smc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 5b932583e407..d9566e84f2f9 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -123,6 +123,12 @@ struct proto smc_proto6 = {
123}; 123};
124EXPORT_SYMBOL_GPL(smc_proto6); 124EXPORT_SYMBOL_GPL(smc_proto6);
125 125
126static void smc_restore_fallback_changes(struct smc_sock *smc)
127{
128 smc->clcsock->file->private_data = smc->sk.sk_socket;
129 smc->clcsock->file = NULL;
130}
131
126static int __smc_release(struct smc_sock *smc) 132static int __smc_release(struct smc_sock *smc)
127{ 133{
128 struct sock *sk = &smc->sk; 134 struct sock *sk = &smc->sk;
@@ -141,6 +147,7 @@ static int __smc_release(struct smc_sock *smc)
141 } 147 }
142 sk->sk_state = SMC_CLOSED; 148 sk->sk_state = SMC_CLOSED;
143 sk->sk_state_change(sk); 149 sk->sk_state_change(sk);
150 smc_restore_fallback_changes(smc);
144 } 151 }
145 152
146 sk->sk_prot->unhash(sk); 153 sk->sk_prot->unhash(sk);