summaryrefslogtreecommitdiffstats
path: root/net/smc
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-02-18 18:32:59 +0300
committerDavid S. Miller <davem@davemloft.net>2022-02-19 18:54:43 +0000
commit7a11455f376de8a4357af4a20ae68fefe29b8ceb (patch)
tree1ed42e2be252b024963ec1073be20815e49b15c1 /net/smc
parenta7f4f13a0a6836b52ddce38b69eae84a2434fbd6 (diff)
downloadlinux-stable-7a11455f376de8a4357af4a20ae68fefe29b8ceb.tar.gz
linux-stable-7a11455f376de8a4357af4a20ae68fefe29b8ceb.tar.bz2
linux-stable-7a11455f376de8a4357af4a20ae68fefe29b8ceb.zip
net/smc: unlock on error paths in __smc_setsockopt()
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> Reviewed-by: D. Wythe <alibuda@linux.alibaba.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/smc')
-rw-r--r--net/smc/af_smc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index b40ae4d28cbf..30acc31b2c45 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;