From patchwork Fri Feb 5 21:08:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 8239311 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DCE29BEEE5 for ; Fri, 5 Feb 2016 21:08:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1182920383 for ; Fri, 5 Feb 2016 21:08:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CF2E203AC for ; Fri, 5 Feb 2016 21:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751505AbcBEVIs (ORCPT ); Fri, 5 Feb 2016 16:08:48 -0500 Received: from mx143.netapp.com ([216.240.21.24]:25302 "EHLO mx143.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221AbcBEVIr (ORCPT ); Fri, 5 Feb 2016 16:08:47 -0500 X-IronPort-AV: E=Sophos;i="5.22,402,1449561600"; d="scan'208";a="95235526" Received: from vmwexchts03-prd.hq.netapp.com ([10.122.105.31]) by mx143-out.netapp.com with ESMTP; 05 Feb 2016 13:08:47 -0800 Received: from smtp2.corp.netapp.com (10.57.159.114) by VMWEXCHTS03-PRD.hq.netapp.com (10.122.105.31) with Microsoft SMTP Server id 15.0.1130.7; Fri, 5 Feb 2016 13:08:47 -0800 Received: from localhost.localdomain (andros-new.vpn.netapp.com [10.55.67.64]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id u15L8ivZ027795; Fri, 5 Feb 2016 13:08:46 -0800 (PST) From: To: CC: , Andy Adamson Subject: [PATCH RFC Version 1 2/6] SUNRPC fix rpc_clnt_xprt_iter_init infinite loop Date: Fri, 5 Feb 2016 16:08:34 -0500 Message-ID: <1454706518-4641-3-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1454706518-4641-1-git-send-email-andros@netapp.com> References: <1454706518-4641-1-git-send-email-andros@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Adamson xprt_iter_get_next() will restart at top of list and never stop. Only process xps_nxprts xprts. Signed-off-by: Andy Adamson --- 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)