aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-06-27 16:57:12 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-07-15 18:58:49 -0400
commit499f3edc23ca0431f3a0a6736b3a40944c81bf3b (patch)
tree3c07c63facd0387cf921ce56f9062d14c1edacc2 /fs/nfsd
parent17456804546b78a1c13d2b934c8f50bbde141a38 (diff)
nfsd4: remember to put RW access on stateid destruction
Without this, for example, open read open read+write close will result in a struct file leak. Regression from 7d94784293096c0a46897acdb83be5abd9278ece "nfsd4: fix downgrade/lock logic". Cc: stable@kernel.org Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4state.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 12244cee1680..5e8806a9ef4e 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -385,14 +385,6 @@ static int nfs4_access_to_omode(u32 access)
385 BUG(); 385 BUG();
386} 386}
387 387
388static int nfs4_access_bmap_to_omode(struct nfs4_stateid *stp)
389{
390 unsigned int access;
391
392 set_access(&access, stp->st_access_bmap);
393 return nfs4_access_to_omode(access);
394}
395
396static void unhash_generic_stateid(struct nfs4_stateid *stp) 388static void unhash_generic_stateid(struct nfs4_stateid *stp)
397{ 389{
398 list_del(&stp->st_hash); 390 list_del(&stp->st_hash);
@@ -402,11 +394,14 @@ static void unhash_generic_stateid(struct nfs4_stateid *stp)
402 394
403static void free_generic_stateid(struct nfs4_stateid *stp) 395static void free_generic_stateid(struct nfs4_stateid *stp)
404{ 396{
405 int oflag; 397 int i;
406 398
407 if (stp->st_access_bmap) { 399 if (stp->st_access_bmap) {
408 oflag = nfs4_access_bmap_to_omode(stp); 400 for (i = 1; i < 4; i++) {
409 nfs4_file_put_access(stp->st_file, oflag); 401 if (test_bit(i, &stp->st_access_bmap))
402 nfs4_file_put_access(stp->st_file,
403 nfs4_access_to_omode(i));
404 }
410 } 405 }
411 put_nfs4_file(stp->st_file); 406 put_nfs4_file(stp->st_file);
412 kmem_cache_free(stateid_slab, stp); 407 kmem_cache_free(stateid_slab, stp);