From patchwork Fri Apr 5 21:16:27 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 2400501 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 50FB2DF2E5 for ; Fri, 5 Apr 2013 21:16:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162696Ab3DEVQe (ORCPT ); Fri, 5 Apr 2013 17:16:34 -0400 Received: from mx12.netapp.com ([216.240.18.77]:61793 "EHLO mx12.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162478Ab3DEVQd (ORCPT ); Fri, 5 Apr 2013 17:16:33 -0400 X-IronPort-AV: E=Sophos;i="4.87,416,1363158000"; d="scan'208";a="37600218" Received: from smtp2.corp.netapp.com ([10.57.159.114]) by mx12-out.netapp.com with ESMTP; 05 Apr 2013 14:16:33 -0700 Received: from leira.trondhjem.org.com (leira.trondhjem.org.vpn.netapp.com [10.63.228.179]) by smtp2.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id r35LGUnJ014434; Fri, 5 Apr 2013 14:16:32 -0700 (PDT) From: Trond Myklebust To: linux-nfs@vger.kernel.org Cc: Chuck Lever , Bryan Schumaker Subject: [PATCH 1/2] NFSv4: Fix a memory leak in nfs4_discover_server_trunking Date: Fri, 5 Apr 2013 17:16:27 -0400 Message-Id: <1365196588-25403-2-git-send-email-Trond.Myklebust@netapp.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1365196588-25403-1-git-send-email-Trond.Myklebust@netapp.com> References: <1365196588-25403-1-git-send-email-Trond.Myklebust@netapp.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When we assign a new rpc_client to clp->cl_rpcclient, we need to destroy the old one. Signed-off-by: Trond Myklebust Cc: Chuck Lever Cc: stable@vger.kernel.org [>=3.7] --- fs/nfs/nfs4state.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index 6ace365..d41a351 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -1886,7 +1886,13 @@ again: status = PTR_ERR(clnt); break; } - clp->cl_rpcclient = clnt; + /* Note: this is safe because we haven't yet marked the + * client as ready, so we are the only user of + * clp->cl_rpcclient + */ + clnt = xchg(&clp->cl_rpcclient, clnt); + rpc_shutdown_client(clnt); + clnt = clp->cl_rpcclient; goto again; case -NFS4ERR_MINOR_VERS_MISMATCH: