From: "Schumaker, Anna" <Anna.Schumaker@netapp.com>
To: "wenwen@cs.uga.edu" <wenwen@cs.uga.edu>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"trond.myklebust@hammerspace.com"
<trond.myklebust@hammerspace.com>
Subject: Re: [PATCH] NFSv4: Fix a memory leak bug
Date: Tue, 20 Aug 2019 13:41:51 +0000 [thread overview]
Message-ID: <bf426508041337ff4059ca2cf02022a151134e5a.camel@netapp.com> (raw)
In-Reply-To: <1566287651-11386-1-git-send-email-wenwen@cs.uga.edu>
Hi Wenwen,
On Tue, 2019-08-20 at 02:54 -0500, Wenwen Wang wrote:
> 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 <wenwen@cs.uga.edu>
> ---
> 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;
Thanks for the suggestion! I think a better option would be to switch
the "return status" into a "goto out" so we can keep all our cleanup
code in a single place in case we ever need to change it in the future.
What do you think?
Anna
> + }
>
> status = nfs4_replace_transport(server, locations);
> if (status != 0) {
> --
> 2.7.4
>
next prev parent reply other threads:[~2019-08-20 13:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 7:54 Wenwen Wang
2019-08-20 13:41 ` Schumaker, Anna [this message]
2019-08-20 18:53 ` Wenwen Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bf426508041337ff4059ca2cf02022a151134e5a.camel@netapp.com \
--to=anna.schumaker@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
--cc=wenwen@cs.uga.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®