All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaohui Zhang <ruc_zhangxiaohui@163.com>
To: Xiaohui Zhang <ruc_zhangxiaohui@163.com>,
	Trond Myklebust <trond.myklebust@hammerspace.com>,
	Anna Schumaker <anna@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: hifoolno <553441439@qq.com>
Subject: [PATCH 2/2] SUNRPC: Fix infinite looping in rpc_clnt_iterate_for_each_xprt
Date: Sat,  4 Jun 2022 11:28:10 +0800	[thread overview]
Message-ID: <20220604032810.12602-1-ruc_zhangxiaohui@163.com> (raw)

From: hifoolno <553441439@qq.com>

If there were less than 2 entries in the multipath list, then
xprt_iter_current_entry() would never advance beyond the
first entry, which is correct for round robin behaviour, but not
for the list iteration.

The end result would be infinite looping in rpc_clnt_iterate_for_each_xprt()
as we would never see the xprt == NULL condition fulfilled.

Signed-off-by: hifoolno <553441439@qq.com>
---
 net/sunrpc/xprtmultipath.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c
index 1693f81aae37..23c3aae1bb5b 100644
--- a/net/sunrpc/xprtmultipath.c
+++ b/net/sunrpc/xprtmultipath.c
@@ -278,14 +278,12 @@ static
 struct rpc_xprt *xprt_iter_current_entry(struct rpc_xprt_iter *xpi)
 {
 	struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
-	struct list_head *head;
 
 	if (xps == NULL)
 		return NULL;
-	head = &xps->xps_xprt_list;
-	if (xpi->xpi_cursor == NULL || xps->xps_nxprts < 2)
-		return xprt_switch_find_first_entry(head);
-	return xprt_switch_find_current_entry(head, xpi->xpi_cursor);
+	return xprt_switch_set_next_cursor(&xps->xps_xprt_list,
+		&xpi->xpi_cursor,
+		find_next);
 }
 
 bool rpc_xprt_switch_has_addr(struct rpc_xprt_switch *xps,
-- 
2.17.1


                 reply	other threads:[~2022-06-04  3:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220604032810.12602-1-ruc_zhangxiaohui@163.com \
    --to=ruc_zhangxiaohui@163.com \
    --cc=553441439@qq.com \
    --cc=anna@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=trond.myklebust@hammerspace.com \
    /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 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.