mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Karsten Graul <kgraul@linux.ibm.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>,
	davem@davemloft.net, kuba@kernel.org
Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: smc: fix error return code of smc_diag_dump_proto()
Date: Fri, 5 Mar 2021 11:30:20 +0100	[thread overview]
Message-ID: <d1d50e39-e496-1060-2c71-2338c0572c55@linux.ibm.com> (raw)
In-Reply-To: <20210305101351.14683-1-baijiaju1990@gmail.com>

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)

      reply	other threads:[~2021-03-05 10:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 10:13 Jia-Ju Bai
2021-03-05 10:30 ` Karsten Graul [this message]

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=d1d50e39-e496-1060-2c71-2338c0572c55@linux.ibm.com \
    --to=kgraul@linux.ibm.com \
    --cc=baijiaju1990@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®