All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt()
@ 2022-02-18 15:32 Dan Carpenter
  2022-02-19  7:05 ` D. Wythe
  2022-02-19 19:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-02-18 15:32 UTC (permalink / raw)
  To: Karsten Graul, D. Wythe
  Cc: David S. Miller, Jakub Kicinski, linux-s390, netdev, kernel-janitors

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt()
  2022-02-18 15:32 [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt() Dan Carpenter
@ 2022-02-19  7:05 ` D. Wythe
  2022-02-19 19:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: D. Wythe @ 2022-02-19  7:05 UTC (permalink / raw)
  To: Dan Carpenter, Karsten Graul
  Cc: David S. Miller, Jakub Kicinski, linux-s390, netdev, kernel-janitors



在 2022/2/18 下午11:32, 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 <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;

My mistake... thanks for your fixes.

Reviewed-by: D. Wythe <alibuda@linux.alibaba.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt()
  2022-02-18 15:32 [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt() Dan Carpenter
  2022-02-19  7:05 ` D. Wythe
@ 2022-02-19 19:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-02-19 19:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: kgraul, alibuda, davem, kuba, linux-s390, netdev, kernel-janitors

Hello:

This patch was applied to netdev/net-next.git (master)
by David S. Miller <davem@davemloft.net>:

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 <dan.carpenter@oracle.com>
> ---
>  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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-19 19:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-18 15:32 [PATCH net-next] net/smc: unlock on error paths in __smc_setsockopt() Dan Carpenter
2022-02-19  7:05 ` D. Wythe
2022-02-19 19:00 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.