net/smc: unlock on error paths in __smc_setsockopt()
Subsystems (5)
PATCH 1/1 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 <[email protected]>
--- net/smc/af_smc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/smc/af_smc.c +8 -4
@@ -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 ;
Signature · 1 line
2.20.1
Quoted 21 lines · Dan Carpenter
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 <[email protected]>--- net/smc/af_smc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)net/smc/af_smc.c +1
-4@@ -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 )) {
net/smc/af_smc.c static int __smc_setsockopt(struct socket *sock, int level, int optname, · line 2728
Quoted 10 lines
net/smc/af_smc.c +7
-0+ rc = -EINVAL ; +break ; + } +if (copy_from_sockptr (&val, optval,sizeof (int ))) { + rc = -EFAULT ; +break ; + } smc->limit_smc_hs = !!val; rc =0 ;
My mistake... thanks for your fixes.
Reviewed-by D. Wythe <[email protected]>
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 7 lines · On Fri, 18 Feb 2022 18:32:59 +0300 you wrote:
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 <[email protected]>--- net/smc/af_smc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
Here is the summary with links:
- [net-next] net/smc: unlock on error paths in __smc_setsockopt()
https://git.kernel.org/netdev/net-next/c/7a11455f376d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html