Skip to content

Commit

Permalink
nfsd4: remember to put RW access on stateid destruction
Browse files Browse the repository at this point in the history
Without this, for example,

	open read
	open read+write
	close

will result in a struct file leak.

Regression from 7d94784 "nfsd4: fix
downgrade/lock logic".

Cc: stable@kernel.org
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
J. Bruce Fields committed Jul 15, 2011
1 parent 1745680 commit 499f3ed
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,6 @@ static int nfs4_access_to_omode(u32 access)
BUG();
}

static int nfs4_access_bmap_to_omode(struct nfs4_stateid *stp)
{
unsigned int access;

set_access(&access, stp->st_access_bmap);
return nfs4_access_to_omode(access);
}

static void unhash_generic_stateid(struct nfs4_stateid *stp)
{
list_del(&stp->st_hash);
Expand All @@ -402,11 +394,14 @@ static void unhash_generic_stateid(struct nfs4_stateid *stp)

static void free_generic_stateid(struct nfs4_stateid *stp)
{
int oflag;
int i;

if (stp->st_access_bmap) {
oflag = nfs4_access_bmap_to_omode(stp);
nfs4_file_put_access(stp->st_file, oflag);
for (i = 1; i < 4; i++) {
if (test_bit(i, &stp->st_access_bmap))
nfs4_file_put_access(stp->st_file,
nfs4_access_to_omode(i));
}
}
put_nfs4_file(stp->st_file);
kmem_cache_free(stateid_slab, stp);
Expand Down

0 comments on commit 499f3ed

Please sign in to comment.