mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
NFSv4: Fix memory and state leak in _nfs4_open_and_get_state
commita974deee47upstream. 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:3efb972247("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a3c6cbc4ea
commit
0465339eb5
@@ -2708,6 +2708,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);
|
||||||
if (opendata->o_res.rflags & NFS4_OPEN_RESULT_MAY_NOTIFY_LOCK)
|
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,
|
|||||||
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))
|
||||||
|
|||||||
Reference in New Issue
Block a user