From: Trond Myklebust <trondmy@kernel.org>
To: Li Lingfeng <lilingfeng3@huawei.com>, anna@kernel.org
Cc: jlayton@kernel.org, linux-nfs@vger.kernel.org,
linux-kernel@vger.kernel.org, yukuai1@huaweicloud.com,
houtao1@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com,
lilingfeng@huaweicloud.com
Subject: Re: [PATCH] nfs: fix memory leak in error path of nfs4_do_reclaim
Date: Wed, 04 Sep 2024 10:38:45 -0400 [thread overview]
Message-ID: <8ee4ce7c4eb56ec80365492407b76ee3dc4b6347.camel@kernel.org> (raw)
In-Reply-To: <20240904123457.3027627-1-lilingfeng3@huawei.com>
On Wed, 2024-09-04 at 20:34 +0800, Li Lingfeng wrote:
> Commit c77e22834ae9 ("NFSv4: Fix a potential sleep while atomic in
> nfs4_do_reclaim()") separate out the freeing of the state owners from
> nfs4_purge_state_owners() and finish it outside the rcu lock.
> However, the error path is omitted. As a result, the state owners in
> "freeme" will not be released.
> Fix it by adding freeing in the error path.
>
> Fixes: c77e22834ae9 ("NFSv4: Fix a potential sleep while atomic in
> nfs4_do_reclaim()")
> Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com>
> ---
> fs/nfs/nfs4state.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
> index 877f682b45f2..30aba1dedaba 100644
> --- a/fs/nfs/nfs4state.c
> +++ b/fs/nfs/nfs4state.c
> @@ -1957,6 +1957,7 @@ static int nfs4_do_reclaim(struct nfs_client
> *clp, const struct nfs4_state_recov
> set_bit(ops->owner_flag_bit, &sp-
> >so_flags);
> nfs4_put_state_owner(sp);
> status =
> nfs4_recovery_handle_error(clp, status);
> + nfs4_free_state_owners(&freeme);
> return (status != 0) ? status : -
> EAGAIN;
> }
>
Nice catch! Yes, that leak has been there for quite a while. Thanks for
finding it.
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2024-09-04 14:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-04 12:34 Li Lingfeng
2024-09-04 14:38 ` Trond Myklebust [this message]
2024-09-04 20:15 ` Anna Schumaker
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=8ee4ce7c4eb56ec80365492407b76ee3dc4b6347.camel@kernel.org \
--to=trondmy@kernel.org \
--cc=anna@kernel.org \
--cc=houtao1@huawei.com \
--cc=jlayton@kernel.org \
--cc=lilingfeng3@huawei.com \
--cc=lilingfeng@huaweicloud.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.com \
/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®