Commit 6b553b7a authored by Trond Myklebust's avatar Trond Myklebust Committed by Greg Kroah-Hartman

SUNRPC: Fix infinite looping in rpc_clnt_iterate_for_each_xprt

commit bdc54d8e upstream.

If there were less than 2 entries in the multipath list, then
xprt_iter_next_entry_multiple() 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.
Reported-by: default avatarOleg Drokin <green@linuxhacker.ru>
Fixes: 80b14d5e ("SUNRPC: Add a structure to track multiple transports")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Cc: Jason L Tibbitts III <tibbs@math.uh.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 95f83779
...@@ -271,14 +271,12 @@ struct rpc_xprt *xprt_iter_next_entry_multiple(struct rpc_xprt_iter *xpi, ...@@ -271,14 +271,12 @@ struct rpc_xprt *xprt_iter_next_entry_multiple(struct rpc_xprt_iter *xpi,
xprt_switch_find_xprt_t find_next) xprt_switch_find_xprt_t find_next)
{ {
struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
struct list_head *head;
if (xps == NULL) if (xps == NULL)
return NULL; return NULL;
head = &xps->xps_xprt_list; return xprt_switch_set_next_cursor(&xps->xps_xprt_list,
if (xps->xps_nxprts < 2) &xpi->xpi_cursor,
return xprt_switch_find_first_entry(head); find_next);
return xprt_switch_set_next_cursor(head, &xpi->xpi_cursor, find_next);
} }
static static
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment