]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.1/nfsd4-remember-to-put-rw-access-on-stateid-destruction.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.0.1 / nfsd4-remember-to-put-rw-access-on-stateid-destruction.patch
1 From 499f3edc23ca0431f3a0a6736b3a40944c81bf3b Mon Sep 17 00:00:00 2001
2 From: "J. Bruce Fields" <bfields@redhat.com>
3 Date: Mon, 27 Jun 2011 16:57:12 -0400
4 Subject: nfsd4: remember to put RW access on stateid destruction
5
6 From: "J. Bruce Fields" <bfields@redhat.com>
7
8 commit 499f3edc23ca0431f3a0a6736b3a40944c81bf3b upstream.
9
10 Without this, for example,
11
12 open read
13 open read+write
14 close
15
16 will result in a struct file leak.
17
18 Regression from 7d94784293096c0a46897acdb83be5abd9278ece "nfsd4: fix
19 downgrade/lock logic".
20
21 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
23
24 ---
25 fs/nfsd/nfs4state.c | 17 ++++++-----------
26 1 file changed, 6 insertions(+), 11 deletions(-)
27
28 --- a/fs/nfsd/nfs4state.c
29 +++ b/fs/nfsd/nfs4state.c
30 @@ -381,14 +381,6 @@ static int nfs4_access_to_omode(u32 acce
31 BUG();
32 }
33
34 -static int nfs4_access_bmap_to_omode(struct nfs4_stateid *stp)
35 -{
36 - unsigned int access;
37 -
38 - set_access(&access, stp->st_access_bmap);
39 - return nfs4_access_to_omode(access);
40 -}
41 -
42 static void unhash_generic_stateid(struct nfs4_stateid *stp)
43 {
44 list_del(&stp->st_hash);
45 @@ -398,11 +390,14 @@ static void unhash_generic_stateid(struc
46
47 static void free_generic_stateid(struct nfs4_stateid *stp)
48 {
49 - int oflag;
50 + int i;
51
52 if (stp->st_access_bmap) {
53 - oflag = nfs4_access_bmap_to_omode(stp);
54 - nfs4_file_put_access(stp->st_file, oflag);
55 + for (i = 1; i < 4; i++) {
56 + if (test_bit(i, &stp->st_access_bmap))
57 + nfs4_file_put_access(stp->st_file,
58 + nfs4_access_to_omode(i));
59 + }
60 }
61 put_nfs4_file(stp->st_file);
62 kmem_cache_free(stateid_slab, stp);