Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3716516ybl; Tue, 20 Aug 2019 00:55:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6GCu8RAtopB4BKiuxu7u1YUgzjvsj+sFOQj74V6WNbHHcmB7MGYOrzdLof85IDUdrbTdt X-Received: by 2002:a17:90a:f48a:: with SMTP id bx10mr25158511pjb.75.1566287732176; Tue, 20 Aug 2019 00:55:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566287732; cv=none; d=google.com; s=arc-20160816; b=oL3RBSVLj8iSTZsaT7vpDSgJN3ASdjuOKNIeCw5zl4+x54YL5+jeLoyPFuVAUlf/ro rO3KME794Ygz8hGZx3aIamxwyO5jtotsexc0gZCL4GiHe77+T77mFOtpiVAxG4vrDwzo vp/ZQTnPFg5TgxstklGq2uTcWKH8QpoAqQaaczxWkx/mu95P1LFlqnYhQoWXcTghrLFK eBRbmM72gwOYd112nol4ZyOrLNMun+JLCytlXsp+wG3MBITS79V+alFNg7zM9lVu/xDh ywfVE8GjC4S8ZaEGFVu5wss/xyq2DGbsGN0sVKBFjZJYjazVG58B582RRzk0VFsPpH/Z rPaw== 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=OjkK6EB2PuI2qQbEQ93AzCQ5P3wMA5I+qFalZij811o=; b=uxAjkTLL+EmyyBtUcNXjmFG2M197/y6TYcleCUWN0xafOmbKlt2v8woiSH2Z7/qrsY VeYKq7xdqA443NfJYbYYhy/F53BXquryZop+kVokP3gX/rzoxOYyATX5o895JzeWQ/id 5KyZB3dEclyFg2fSaUJ0QG0pvC1Zg8oLnsxQ+3jmXcTA+6QXSk8I7EJ++fmQ/utxU6Zk pbFDmShFOrg7ib/dpIBRhEECjoMj/4mAxZwhlDtBBo8qKkCSaz/IXi/dlRKr7CcapKr4 JqfkRYOtySjBlKDXqYMrZUZWeJrkQbbKag1EK6uGyOLajJ0e78/Puy96dnnEZJG9AW8O uAUQ== 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 k1si10430118pje.17.2019.08.20.00.55.05; Tue, 20 Aug 2019 00:55:32 -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 S1729374AbfHTHyT (ORCPT + 99 others); Tue, 20 Aug 2019 03:54:19 -0400 Received: from mail-yb1-f196.google.com ([209.85.219.196]:43696 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfHTHyT (ORCPT ); Tue, 20 Aug 2019 03:54:19 -0400 Received: by mail-yb1-f196.google.com with SMTP id o82so1655127ybg.10; Tue, 20 Aug 2019 00:54:18 -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=OjkK6EB2PuI2qQbEQ93AzCQ5P3wMA5I+qFalZij811o=; b=gXa6zBs/Vbdo8i/Zn03xEZQldj+P0MbGSsCx3mhD9VSJDB4G3745OtRwYKBq9yL+Px E+v393O7WKDAy03bintkbcCfgUkADvdcHbXiCYOeNUnfLgYyMYFGKpjB7tbizkGMlYSM Rbz4GqZNIKwn4Woq44OATK5tKqZk3uBxzX211wHKoSCXEGaZlzWZxxTKz4SaiflXZEd9 n+lLJbUulxjxxvaF3/z9F+gZgYfFOJV+HGJLRFprAAr67hfwWv5v6Y+sYN4Lji/qAa8k tmk8ZUVYWPvX83XBZksu9gK5Pkqc2rogU/FzUXU9aB7h7OeQ7xuIECZBTtNVPP6i5U6p oIbg== X-Gm-Message-State: APjAAAVX0n8mH58giXg15G46LDkALP40dS+TNcBm6oMyR8UBI8qSUrw8 igAenpH2qBWRCS8aZDPxrWk= X-Received: by 2002:a25:2403:: with SMTP id k3mr18920369ybk.377.1566287658366; Tue, 20 Aug 2019 00:54:18 -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 t63sm3448566ywf.92.2019.08.20.00.54.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Aug 2019 00:54:16 -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] NFSv4: Fix a memory leak bug Date: Tue, 20 Aug 2019 02:54:10 -0500 Message-Id: <1566287651-11386-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, free 'page' and 'locations' before returning the error. Signed-off-by: Wenwen Wang --- fs/nfs/nfs4state.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c index cad4e06..37823dc 100644 --- a/fs/nfs/nfs4state.c +++ b/fs/nfs/nfs4state.c @@ -2095,8 +2095,12 @@ static int nfs4_try_migration(struct nfs_server *server, const struct cred *cred } status = nfs4_begin_drain_session(clp); - if (status != 0) + if (status != 0) { + if (page != NULL) + __free_page(page); + kfree(locations); return status; + } status = nfs4_replace_transport(server, locations); if (status != 0) { -- 2.7.4