summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtmultipath.c
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2016-07-16 11:47:00 -0400
committerTrond Myklebust <trond.myklebust@primarydata.com>2016-07-16 11:59:35 -0400
commitbdc54d8e3cb4a41dddcabfd86d9eb3aa5f622b75 (patch)
tree7bfca83d058439ba9b7f35da06801d0143832b5a /net/sunrpc/xprtmultipath.c
parent9ffadfbc092fc25d9639a019fb3079cf352ef978 (diff)
SUNRPC: Fix infinite looping in rpc_clnt_iterate_for_each_xprt
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: Oleg Drokin <green@linuxhacker.ru> Fixes: 80b14d5e61ca ("SUNRPC: Add a structure to track multiple transports") Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'net/sunrpc/xprtmultipath.c')
-rw-r--r--net/sunrpc/xprtmultipath.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/net/sunrpc/xprtmultipath.c b/net/sunrpc/xprtmultipath.c
index e7fd76975d86..66c9d63f4797 100644
--- a/net/sunrpc/xprtmultipath.c
+++ b/net/sunrpc/xprtmultipath.c
@@ -271,14 +271,12 @@ struct rpc_xprt *xprt_iter_next_entry_multiple(struct rpc_xprt_iter *xpi,
271 xprt_switch_find_xprt_t find_next) 271 xprt_switch_find_xprt_t find_next)
272{ 272{
273 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch); 273 struct rpc_xprt_switch *xps = rcu_dereference(xpi->xpi_xpswitch);
274 struct list_head *head;
275 274
276 if (xps == NULL) 275 if (xps == NULL)
277 return NULL; 276 return NULL;
278 head = &xps->xps_xprt_list; 277 return xprt_switch_set_next_cursor(&xps->xps_xprt_list,
279 if (xps->xps_nxprts < 2) 278 &xpi->xpi_cursor,
280 return xprt_switch_find_first_entry(head); 279 find_next);
281 return xprt_switch_set_next_cursor(head, &xpi->xpi_cursor, find_next);
282} 280}
283 281
284static 282static