Skip to content

Commit a974dee

Browse files
trondmypdamschuma-ntap
authored andcommitted
NFSv4: Fix memory and state leak in _nfs4_open_and_get_state
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: 3efb972 ("NFSv4: Refactor _nfs4_open_and_get_state..") Cc: stable@vger.kernel.org # 3.10+ Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent 8ccc869 commit a974dee

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎fs/nfs/nfs4proc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,7 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
26242624
ret = PTR_ERR(state);
26252625
if (IS_ERR(state))
26262626
goto out;
2627+
ctx->state = state;
26272628
if (server->caps & NFS_CAP_POSIX_LOCK)
26282629
set_bit(NFS_STATE_POSIX_LOCKS, &state->flags);
26292630
if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK)
@@ -2649,7 +2650,6 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
26492650
if (ret != 0)
26502651
goto out;
26512652

2652-
ctx->state = state;
26532653
if (d_inode(dentry) == state->inode) {
26542654
nfs_inode_attach_open_context(ctx);
26552655
if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))

0 commit comments

Comments
 (0)