summaryrefslogtreecommitdiffstats
path: root/net/smc/smc_close.c
diff options
context:
space:
mode:
authorKarsten Graul <kgraul@linux.ibm.com>2020-09-15 22:57:09 +0200
committerDavid S. Miller <davem@davemloft.net>2020-09-17 02:30:16 +0200
commitddcc9b7feb451c5c8145d11879a6585a4ddd317d (patch)
treec54b68fed6a535142fecd440b1abd72478ffe8db /net/smc/smc_close.c
parentnet: bridge: mcast: don't ignore return value of __grp_src_toex_excl (diff)
downloadlinux-ddcc9b7feb451c5c8145d11879a6585a4ddd317d.tar.xz
linux-ddcc9b7feb451c5c8145d11879a6585a4ddd317d.zip
net/smc: check variable before dereferencing in smc_close.c
smc->clcsock and smc->clcsock->sk are used before the check if they can be dereferenced. Fix this by checking the variables first. Fixes: a60a2b1e0af1 ("net/smc: reduce active tcp_listen workers") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/smc/smc_close.c')
-rw-r--r--net/smc/smc_close.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/net/smc/smc_close.c b/net/smc/smc_close.c
index 10d05a6d34fc..0f9ffba07d26 100644
--- a/net/smc/smc_close.c
+++ b/net/smc/smc_close.c
@@ -208,11 +208,12 @@ again:
break;
case SMC_LISTEN:
sk->sk_state = SMC_CLOSED;
- smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready;
- smc->clcsock->sk->sk_user_data = NULL;
sk->sk_state_change(sk); /* wake up accept */
- if (smc->clcsock && smc->clcsock->sk)
+ if (smc->clcsock && smc->clcsock->sk) {
+ smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready;
+ smc->clcsock->sk->sk_user_data = NULL;
rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
+ }
smc_close_cleanup_listen(sk);
release_sock(sk);
flush_work(&smc->tcp_listen_work);