Commit 52fb4bdc authored by Trond Myklebust's avatar Trond Myklebust Committed by Greg Kroah-Hartman

NFSv4: Fix memory and state leak in _nfs4_open_and_get_state

commit a974deee upstream.

If we exit because the file access check failed, we currently
leak the struct nfs4_state. We need to attach it to the
open context before returning.

Fixes: 3efb9722 ("NFSv4: Refactor _nfs4_open_and_get_state..")
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3ee4f442
...@@ -2452,6 +2452,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, ...@@ -2452,6 +2452,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
ret = PTR_ERR(state); ret = PTR_ERR(state);
if (IS_ERR(state)) if (IS_ERR(state))
goto out; goto out;
ctx->state = state;
if (server->caps & NFS_CAP_POSIX_LOCK) if (server->caps & NFS_CAP_POSIX_LOCK)
set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
...@@ -2474,7 +2475,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, ...@@ -2474,7 +2475,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
if (ret != 0) if (ret != 0)
goto out; goto out;
ctx->state = state;
if (d_inode(dentry) == state->inode) { if (d_inode(dentry) == state->inode) {
nfs_inode_attach_open_context(ctx); nfs_inode_attach_open_context(ctx);
if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment