diff options
author | Trond Myklebust <trond.myklebust@primarydata.com> | 2017-02-08 11:29:46 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-03-12 00:41:51 -0500 |
commit | 0465339eb54953f0be1f03e980b07eeb01e16fca (patch) | |
tree | 6bd30e1ff461827015fae7513be1c66522982f84 /fs | |
parent | a3c6cbc4eac4473ed5461d5faae2794d3e5c0e44 (diff) |
NFSv4: Fix memory and state leak in _nfs4_open_and_get_state
commit a974deee477af89411e0f80456bfb344ac433c98 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: 3efb9722475e ("NFSv4: Refactor _nfs4_open_and_get_state..")
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/nfs4proc.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 78ff8b63d5f7..123105f4be53 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -2708,6 +2708,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, | |||
2708 | ret = PTR_ERR(state); | 2708 | ret = PTR_ERR(state); |
2709 | if (IS_ERR(state)) | 2709 | if (IS_ERR(state)) |
2710 | goto out; | 2710 | goto out; |
2711 | ctx->state = state; | ||
2711 | if (server->caps & NFS_CAP_POSIX_LOCK) | 2712 | if (server->caps & NFS_CAP_POSIX_LOCK) |
2712 | set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); | 2713 | set_bit(NFS_STATE_POSIX_LOCKS, &state->flags); |
2713 | if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK) | 2714 | if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK) |
@@ -2733,7 +2734,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata, | |||
2733 | if (ret != 0) | 2734 | if (ret != 0) |
2734 | goto out; | 2735 | goto out; |
2735 | 2736 | ||
2736 | ctx->state = state; | ||
2737 | if (d_inode(dentry) == state->inode) { | 2737 | if (d_inode(dentry) == state->inode) { |
2738 | nfs_inode_attach_open_context(ctx); | 2738 | nfs_inode_attach_open_context(ctx); |
2739 | if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) | 2739 | if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq)) |