From: Karsten Graul <kgraul@linux.ibm.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, linux-s390@vger.kernel.org,
heiko.carstens@de.ibm.com, raspl@linux.ibm.com,
ubraun@linux.ibm.com
Subject: [PATCH net-next 1/1] net/smc: check variable before dereferencing in smc_close.c
Date: Tue, 15 Sep 2020 22:57:09 +0200 [thread overview]
Message-ID: <20200915205709.50325-2-kgraul@linux.ibm.com> (raw)
In-Reply-To: <20200915205709.50325-1-kgraul@linux.ibm.com>
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>
---
net/smc/smc_close.c | 7 ++++---
1 file 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 @@ 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);
--
2.17.1
next prev parent reply other threads:[~2020-09-15 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 20:57 [PATCH net-next 0/1] net/smc: fix 2020-09-15 Karsten Graul
2020-09-15 20:57 ` Karsten Graul [this message]
2020-09-17 0:34 ` [PATCH net-next 1/1] net/smc: check variable before dereferencing in smc_close.c David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200915205709.50325-2-kgraul@linux.ibm.com \
--to=kgraul@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=heiko.carstens@de.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=raspl@linux.ibm.com \
--cc=ubraun@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).