From: Dan Carpenter <dan.carpenter@oracle.com>
To: Karsten Graul <kgraul@linux.ibm.com>,
"D. Wythe" <alibuda@linux.alibaba.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
linux-s390@vger.kernel.org, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt()
Date: Fri, 18 Feb 2022 18:32:59 +0300 [thread overview]
Message-ID: <20220218153259.GA4392@kili> (raw)
These two error paths need to release_sock(sk) before returning.
Fixes: a6a6fe27bab4 ("net/smc: Dynamic control handshake limitation by socket options")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
net/smc/af_smc.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index d873afe2d4dc..38faf2b60327 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -2715,10 +2715,14 @@ static int __smc_setsockopt(struct socket *sock, int level, int optname,
lock_sock(sk);
switch (optname) {
case SMC_LIMIT_HS:
- if (optlen < sizeof(int))
- return -EINVAL;
- if (copy_from_sockptr(&val, optval, sizeof(int)))
- return -EFAULT;
+ if (optlen < sizeof(int)) {
+ rc = -EINVAL;
+ break;
+ }
+ if (copy_from_sockptr(&val, optval, sizeof(int))) {
+ rc = -EFAULT;
+ break;
+ }
smc->limit_smc_hs = !!val;
rc = 0;
--
2.20.1
next reply other threads:[~2022-02-18 15:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-18 15:32 Dan Carpenter [this message]
2022-02-19 7:05 ` [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt() D. Wythe
2022-02-19 19:00 ` patchwork-bot+netdevbpf
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=20220218153259.GA4392@kili \
--to=dan.carpenter@oracle.com \
--cc=alibuda@linux.alibaba.com \
--cc=davem@davemloft.net \
--cc=kernel-janitors@vger.kernel.org \
--cc=kgraul@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).