Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp296318ybl; Tue, 20 Aug 2019 20:22:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhY+HZGI5Ni7TXBPKLvxvBOrMKJ59ob+LABeFWU3XcmrBe8E3Xc0rLVCmsoEQmTSeWV0Je X-Received: by 2002:a62:b60e:: with SMTP id j14mr33843629pff.54.1566357738094; Tue, 20 Aug 2019 20:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566357738; cv=none; d=google.com; s=arc-20160816; b=S+hbQzCX6at8W7iegzYtPyHeYAIfT6SZmpiTGerXo3uSClqLa424+iYyOU4oFY+t3k l4SE2drNJCb3jpN5kO0hUPEGRQtg/XpW0qXFJZL6k4EOcN4A4t4ch9MQKm9G61vsQ/pN a8baZxcMC9LNmw6ksVQb1GI/oxyoiLCr0seBXRs7guGglEHivAgx7INFZn6GqPlMoNq2 0FqW+KPgnKA86H4jfafirxbdpPAaDezZpDWs8XZga1VyVRUY3KBoE8l6aPl+70dpux6k uaeTMi1DqOx3IEW7EY9+IB2y3rZ7P+/6qbljyz3RW3dR9p95w1MtcwXeoyvZ8uAt10rO g5rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=oBua0iXLtvX1pOMS/2zzOhz5z0JgebEFIjoemm0o1zg=; b=bRmdTPjGuIngoYKL2D8BjfhKMA85q+7itHVbKAuugqmCZfhQwjnpaAimXHigt+dH4I UfWZUE2NxghFnslOy0bdoP582ab7qoUAhRheZlTqS5+cOAMo2gdMX6kuxTbdfpkpI7Mv cUW0TQukwHJ/lE1NaHzNzY+cSuwg3v1IWFa5NTHRKjJHR9tDU91+1qCCsVbgTzC6w9n8 idQhK5F+Eay2vN+zv8+85OXa9GQ1a8jTpJdMi3k3GqcK4wqXa76F0gaYjDtircJiOlle j/MIMQji3X1UwWaxSLy6FGqmuUwHN9rns1/FDK27F5OY91Hocq8h6dIGqB1nTla3Xyu1 2m2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h1si1301154pji.79.2019.08.20.20.21.52; Tue, 20 Aug 2019 20:22:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727297AbfHUDV2 (ORCPT + 99 others); Tue, 20 Aug 2019 23:21:28 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:41894 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726693AbfHUDV2 (ORCPT ); Tue, 20 Aug 2019 23:21:28 -0400 Received: by mail-yb1-f193.google.com with SMTP id 1so2799ybj.8; Tue, 20 Aug 2019 20:21:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oBua0iXLtvX1pOMS/2zzOhz5z0JgebEFIjoemm0o1zg=; b=tl8rsslErn9PGe+OVdq/oZpM6lz5Cw9WnJix3wZLV4MDA2WEC38F+41/V/93PZMYpZ FgAhE5MbYjmjIPkON2MY27ZKl59S50+2dmjo5mvH+Eo658Vy7y6l5ptLhXKHD9yCH/cx e7qa5IVLG1QTKt3IHjCUArz0LBtCdBgqmP0iDPGJNw9DlI3e0DB21rSTCv2Vr6jKbvjN xjXYe8w37AQYbxFyw4Dkx0YzbPK4U/j+CtyvbW+GWOtFo7bPI5uG3CFaxAtgsMz0y9Ka LzpZhb6w+wjy4tjfGcWQRvpVaSeKzdStZH4XkjSw+vFLD+LIzP0Kslnb3Wy2rKtWoI80 U3Ag== X-Gm-Message-State: APjAAAX40JpbT0pgDoyVPBazbT/ievSwQxAY0idjnIADKWnW4jast7RW XlODKA1ReXntMIvVfOA3gXk= X-Received: by 2002:a25:bb03:: with SMTP id z3mr22552927ybg.160.1566357687559; Tue, 20 Aug 2019 20:21:27 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id m40sm4228901ywh.2.2019.08.20.20.21.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Aug 2019 20:21:26 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Trond Myklebust , Anna Schumaker , linux-nfs@vger.kernel.org (open list:NFS, SUNRPC, AND LOCKD CLIENTS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] NFSv4: Fix a memory leak bug Date: Tue, 20 Aug 2019 22:21:21 -0500 Message-Id: <1566357681-4586-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org In nfs4_try_migration(), if nfs4_begin_drain_session() fails, the previously allocated 'page' and 'locations' are not deallocated, leading to memory leaks. To fix this issue, go to the 'out' label to free 'page' and 'locations' before returning the error. Signed-off-by: Wenwen Wang --- fs/nfs/nfs4state.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index cad4e06..e916aba 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2095,8 +2095,10 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred } status = nfs4_begin_drain_session(clp); - if (status != 0) - return status; + if (status != 0) { + result = status; + goto out; + } status = nfs4_replace_transport(server, locations); if (status != 0) { -- 2.7.4