Commit ddcc9b7f authored by Karsten Graul's avatar Karsten Graul Committed by David S. Miller

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: a60a2b1e ("net/smc: reduce active tcp_listen workers")
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarKarsten Graul <kgraul@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d5bf31dd
...@@ -208,11 +208,12 @@ int smc_close_active(struct smc_sock *smc) ...@@ -208,11 +208,12 @@ int smc_close_active(struct smc_sock *smc)
break; break;
case SMC_LISTEN: case SMC_LISTEN:
sk->sk_state = SMC_CLOSED; sk->sk_state = SMC_CLOSED;
sk->sk_state_change(sk); /* wake up accept */
if (smc->clcsock && smc->clcsock->sk) {
smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready; smc->clcsock->sk->sk_data_ready = smc->clcsk_data_ready;
smc->clcsock->sk->sk_user_data = NULL; smc->clcsock->sk->sk_user_data = NULL;
sk->sk_state_change(sk); /* wake up accept */
if (smc->clcsock && smc->clcsock->sk)
rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR); rc = kernel_sock_shutdown(smc->clcsock, SHUT_RDWR);
}
smc_close_cleanup_listen(sk); smc_close_cleanup_listen(sk);
release_sock(sk); release_sock(sk);
flush_work(&smc->tcp_listen_work); flush_work(&smc->tcp_listen_work);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment