Skip to content

Commit

Permalink
NFSv4: Fix state reference counting in _nfs4_opendata_reclaim_to_nfs4…
Browse files Browse the repository at this point in the history
…_state

Currently, if the call to nfs_refresh_inode fails, then we end up leaking
a reference count, due to the call to nfs4_get_open_state.
While we're at it, replace nfs4_get_open_state with a simple call to
atomic_inc(); there is no need to do a full lookup of the struct nfs_state
since it is passed as an argument in the struct nfs4_opendata, and
is already assigned to the variable 'state'.

Cc: stable@vger.kernel.org # 3.7.x: a43ec98: NFSv4: don't fail on missing
Cc: stable@vger.kernel.org # 3.7.x
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Oct 28, 2013
1 parent a43ec98 commit d49f042
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1323,11 +1323,6 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
goto err;
}

ret = -ENOMEM;
state = nfs4_get_open_state(inode, data->owner);
if (state == NULL)
goto err;

ret = nfs_refresh_inode(inode, &data->f_attr);
if (ret)
goto err;
Expand All @@ -1336,6 +1331,7 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
nfs4_opendata_check_deleg(data, state);
update_open_stateid(state, &data->o_res.stateid, NULL,
data->o_arg.fmode);
atomic_inc(&state->count);

return state;
err:
Expand Down

0 comments on commit d49f042

Please sign in to comment.