From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E3BEC433DF for ; Tue, 23 Jun 2020 21:43:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4373E2078E for ; Tue, 23 Jun 2020 21:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592948593; bh=uYcJmosV6tInU82yzfrOIp5xqvo2+Hg22rH8s7wwIYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=MrzwwHdz0+/huOps+6P7epG1qi4NCRA3ec7eeJ5z4pjzHAUhBzVqKJnxIDI0K/fAu rKLxxjq07JR8lpxY0kK/YktpYROQIubxSlnY02NiK/LlxP7wZ2QnYvONv5oxkvR+4P I8PuwC5mCgenw61BsJpL/cNc5rdwDzFpQdzK5c2E= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387656AbgFWUEJ (ORCPT ); Tue, 23 Jun 2020 16:04:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:42304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388150AbgFWUEF (ORCPT ); Tue, 23 Jun 2020 16:04:05 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9E8592080C; Tue, 23 Jun 2020 20:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592942645; bh=uYcJmosV6tInU82yzfrOIp5xqvo2+Hg22rH8s7wwIYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BQoit2inrHQhl51aQ8lz917Bw2O5D8rDf4+pDStNVd18pHaRC69qzzFtoud3qBYxh vLMozwK1OipPxNSpMRyc+oVLFn1zSHq0PULf0JC8/0SD9Bt/dg81F6DziOqpAQAElh YxwWTFxACRnNfGS1BRiG9tbBJJ5UjUxFOtdBSzrk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiyu Yang , Xin Tan , "J. Bruce Fields" , Sasha Levin Subject: [PATCH 5.7 080/477] nfsd: Fix svc_xprt refcnt leak when setup callback client failed Date: Tue, 23 Jun 2020 21:51:17 +0200 Message-Id: <20200623195411.393287971@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195407.572062007@linuxfoundation.org> References: <20200623195407.572062007@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xiyu Yang [ Upstream commit a4abc6b12eb1f7a533c2e7484cfa555454ff0977 ] nfsd4_process_cb_update() invokes svc_xprt_get(), which increases the refcount of the "c->cn_xprt". The reference counting issue happens in one exception handling path of nfsd4_process_cb_update(). When setup callback client failed, the function forgets to decrease the refcnt increased by svc_xprt_get(), causing a refcnt leak. Fix this issue by calling svc_xprt_put() when setup callback client failed. Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan Signed-off-by: J. Bruce Fields Signed-off-by: Sasha Levin --- fs/nfsd/nfs4callback.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index 5cf91322de0fc..07e0c6f6322f3 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1301,6 +1301,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) err = setup_callback_client(clp, &conn, ses); if (err) { nfsd4_mark_cb_down(clp, err); + if (c) + svc_xprt_put(c->cn_xprt); return; } } -- 2.25.1