[PATCH RFC Version 1 2/6] SUNRPC fix rpc_clnt_xprt_iter_init infinite loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Andy Adamson <andros@xxxxxxxxxx>

xprt_iter_get_next() will restart at top of list and never stop.
Only process xps_nxprts xprts.

Signed-off-by: Andy Adamson <andros@xxxxxxxxxx>
---
 net/sunrpc/clnt.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index c0469d1..a56a44c8 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -740,6 +740,7 @@ static
 int rpc_clnt_xprt_iter_init(struct rpc_clnt *clnt, struct rpc_xprt_iter *xpi)
 {
 	struct rpc_xprt_switch *xps;
+	int nxprt;
 
 	rcu_read_lock();
 	xps = xprt_switch_get(rcu_dereference(clnt->cl_xpi.xpi_xpswitch));
@@ -747,8 +748,9 @@ int rpc_clnt_xprt_iter_init(struct rpc_clnt *clnt, struct rpc_xprt_iter *xpi)
 	if (xps == NULL)
 		return -EAGAIN;
 	xprt_iter_init_listall(xpi, xps);
+	nxprt = xps->xps_nxprts;
 	xprt_switch_put(xps);
-	return 0;
+	return nxprt;
 }
 
 /**
@@ -767,10 +769,11 @@ int rpc_clnt_iterate_for_each_xprt(struct rpc_clnt *clnt,
 		void *data)
 {
 	struct rpc_xprt_iter xpi;
-	int ret;
+	int ret = 0, nxprts, i;
 
-	ret = rpc_clnt_xprt_iter_init(clnt, &xpi);
-	for (;;) {
+	nxprts = rpc_clnt_xprt_iter_init(clnt, &xpi);
+	dprintk("RPC:   processing nxprts %d\n", nxprts);
+	for (i = 0; i < nxprts; i++) {
 		struct rpc_xprt *xprt = xprt_iter_get_next(&xpi);
 
 		if (!xprt)
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux