aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarsten Graul <kgraul@linux.ibm.com>2020-07-18 15:06:18 +0200
committerPaul Gortmaker <paul.gortmaker@windriver.com>2020-07-24 16:24:34 -0400
commitd1c1762b0623398908339f58ffd03734782b1dde (patch)
tree678d0f17b1c5c70a917106625632cd49c790205e
parent6d1d7538e322ad0d676b8081f6cc973c463e149d (diff)
downloadlinux-yocto-d1c1762b0623398908339f58ffd03734782b1dde.tar.gz
linux-yocto-d1c1762b0623398908339f58ffd03734782b1dde.tar.bz2
linux-yocto-d1c1762b0623398908339f58ffd03734782b1dde.zip
net/smc: fix restoring of fallback changes
commit 1ad24058335427d046b2e5666bcd15a62ad9e242 upstream. When a listen socket is closed then all non-accepted sockets in its accept queue are to be released. Inside __smc_release() the helper smc_restore_fallback_changes() restores the changes done to the socket without to check if the clcsocket has a file set. This can result in a crash. Fix this by checking the file pointer first. Reviewed-by: Ursula Braun <ubraun@linux.ibm.com> Fixes: f536dffc0b79 ("net/smc: fix closing of fallback SMC sockets") Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--net/smc/af_smc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index fe955fae2995..1070e6edeca2 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -125,8 +125,10 @@ EXPORT_SYMBOL_GPL(smc_proto6);
static void smc_restore_fallback_changes(struct smc_sock *smc)
{
- smc->clcsock->file->private_data = smc->sk.sk_socket;
- smc->clcsock->file = NULL;
+ if (smc->clcsock->file) { /* non-accepted sockets have no file yet */
+ smc->clcsock->file->private_data = smc->sk.sk_socket;
+ smc->clcsock->file = NULL;
+ }
}
static int smc_release(struct socket *sock)