Skip to content

Commit

Permalink
net/smc: check variable before dereferencing in smc_close.c
Browse files Browse the repository at this point in the history
smc->clcsock and smc->clcsock->sk are used before the check if they can
be dereferenced. Fix this by checking the variables first.

Fixes: a60a2b1 ("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>
  • Loading branch information
Karsten Graul authored and David S. Miller committed Sep 17, 2020
1 parent d5bf31d commit ddcc9b7
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/smc/smc_close.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,12 @@ int smc_close_active(struct smc_sock *smc)
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);
Expand Down

0 comments on commit ddcc9b7

Please sign in to comment.