All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: smc: fix error return code of smc_diag_dump_proto()
@ 2021-03-05 10:13 Jia-Ju Bai
  2021-03-05 10:30 ` Karsten Graul
  0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2021-03-05 10:13 UTC (permalink / raw)
  To: kgraul, davem, kuba; +Cc: linux-s390, netdev, linux-kernel, Jia-Ju Bai

When the list of head is empty, no error return code of
smc_diag_dump_proto() is assigned.
To fix this bug, rc is assigned with -ENOENT as error return code.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
 net/smc/smc_diag.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c
index c952986a6aca..a90889482842 100644
--- a/net/smc/smc_diag.c
+++ b/net/smc/smc_diag.c
@@ -201,8 +201,10 @@ static int smc_diag_dump_proto(struct proto *prot, struct sk_buff *skb,
 
 	read_lock(&prot->h.smc_hash->lock);
 	head = &prot->h.smc_hash->ht;
-	if (hlist_empty(head))
+	if (hlist_empty(head)) {
+		rc = -ENOENT;
 		goto out;
+	}
 
 	sk_for_each(sk, head) {
 		if (!net_eq(sock_net(sk), net))
-- 
2.17.1


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

* Re: [PATCH] net: smc: fix error return code of smc_diag_dump_proto()
  2021-03-05 10:13 [PATCH] net: smc: fix error return code of smc_diag_dump_proto() Jia-Ju Bai
@ 2021-03-05 10:30 ` Karsten Graul
  0 siblings, 0 replies; 2+ messages in thread
From: Karsten Graul @ 2021-03-05 10:30 UTC (permalink / raw)
  To: Jia-Ju Bai, davem, kuba; +Cc: linux-s390, netdev, linux-kernel

On 05/03/2021 11:13, Jia-Ju Bai wrote:
> When the list of head is empty, no error return code of
> smc_diag_dump_proto() is assigned.
> To fix this bug, rc is assigned with -ENOENT as error return code.

Your change would break smc_diag_dump().
When there are no IPv4 sockets (SMCPROTO_SMC) in the list and -ENOENT 
is returned then smc_diag_dump() will not try to dump any IPv6 sockets
(SMCPROTO_SMC6). Returning zero is correct here.

> 
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
>  net/smc/smc_diag.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c
> index c952986a6aca..a90889482842 100644
> --- a/net/smc/smc_diag.c
> +++ b/net/smc/smc_diag.c
> @@ -201,8 +201,10 @@ static int smc_diag_dump_proto(struct proto *prot, struct sk_buff *skb,
>  
>  	read_lock(&prot->h.smc_hash->lock);
>  	head = &prot->h.smc_hash->ht;
> -	if (hlist_empty(head))
> +	if (hlist_empty(head)) {
> +		rc = -ENOENT;
>  		goto out;
> +	}
>  
>  	sk_for_each(sk, head) {
>  		if (!net_eq(sock_net(sk), net))
> 

-- 
Karsten

(I'm a dude)

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

end of thread, other threads:[~2021-03-05 10:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 10:13 [PATCH] net: smc: fix error return code of smc_diag_dump_proto() Jia-Ju Bai
2021-03-05 10:30 ` Karsten Graul

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.