From patchwork Mon Jun 10 02:16:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nil Yi X-Patchwork-Id: 10983943 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8AF986C5 for ; Mon, 10 Jun 2019 02:17:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B25E287A6 for ; Mon, 10 Jun 2019 02:17:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F999287E0; Mon, 10 Jun 2019 02:17:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0DB40287A6 for ; Mon, 10 Jun 2019 02:17:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730107AbfFJCRM (ORCPT ); Sun, 9 Jun 2019 22:17:12 -0400 Received: from m12-15.163.com ([220.181.12.15]:42115 "EHLO m12-15.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729916AbfFJCRM (ORCPT ); Sun, 9 Jun 2019 22:17:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=VtNxh qgNuhAXI6wf7or1jR1mdLlxPT12xbJh+4Ao0m8=; b=a+fz0lgy0D+3fhqCxAbLQ dTwhQzJHxeGPmLzoh2JJJWZ4pmSDEgoH9YHe4HZcVPmOukEZ/WGSHe9Anl+QcnPk jYOTMfDa9F+cNVmy7ycrMdAwwo7BGb1xmCupMVp3+VDiDoCgqhtP4QUihwcVC5gK 4SpYljXk/FjeDjNj3hhO84= Received: from tero-machine (unknown [124.16.85.90]) by smtp11 (Coremail) with SMTP id D8CowABnZ2WYvf1catboAg--.21215S3; Mon, 10 Jun 2019 10:16:56 +0800 (CST) Date: Mon, 10 Jun 2019 10:16:56 +0800 From: Lin Yi To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com Cc: linux-nfs@vger.kernel.org, liujian6@iie.ac.cn, csong@cs.ucr.edu, zhiyunq@cs.ucr.edu, yiqiuping@gmail.com, teroincn@163.com Subject: [PATCH] net :sunrpc :clnt :Fix xps refcount imbalance on the error path Message-ID: <20190610021655.GA14779@163.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-CM-TRANSID: D8CowABnZ2WYvf1catboAg--.21215S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrAFykuw13uw1rJry7Ww17Jrb_yoWxGwc_Xw 1xXrWxXw4DGanrtFZrAws5CrW7tr40kry8WrnFyrZrXw1UZ3Wjvr93W3Z3Gay7GrWxuasx Ar98G345Cw15tjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU1RpBDUUUUU== X-Originating-IP: [124.16.85.90] X-CM-SenderInfo: 5whu0xxqfqqiywtou0bp/1tbiLxLPElUMNRFJRwAAsT Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rpc_clnt_add_xprt take a reference to struct rpc_xprt_switch, but forget to release it before return, may lead to a memory leak. Signed-off-by: Lin Yi --- net/sunrpc/clnt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 627a87a..2b35347 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -2805,6 +2805,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, xprt = xprt_iter_xprt(&clnt->cl_xpi); if (xps == NULL || xprt == NULL) { rcu_read_unlock(); + xprt_switch_put(xps); return -EAGAIN; } resvport = xprt->resvport;