Commit f2d395865faa2a7cd4620b07178e58cbb160ba08

Authored by NeilBrown
Committed by Linus Torvalds
1 parent e46e490368

[PATCH] knfsd: Fix two problems that can cause rmmod nfsd to die

Both cause the 'entries' count in the export cache to be non-zero at module
removal time, so unregistering that cache fails and results in an oops.

1/ exp_pseudoroot (used for NFSv4 only) leaks a reference to an export
   entry.
2/ sunrpc_cache_update doesn't increment the entries count when it adds
   an entry.

Thanks to "david m.  richter" <richterd@citi.umich.edu> for triggering the
problem and finding one of the bugs.

Cc: "david m. richter" <richterd@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 2 changed files with 4 additions and 1 deletions Side-by-side Diff

... ... @@ -1066,9 +1066,11 @@
1066 1066 rv = nfserr_perm;
1067 1067 else if (IS_ERR(exp))
1068 1068 rv = nfserrno(PTR_ERR(exp));
1069   - else
  1069 + else {
1070 1070 rv = fh_compose(fhp, exp,
1071 1071 fsid_key->ek_dentry, NULL);
  1072 + exp_put(exp);
  1073 + }
1072 1074 cache_put(&fsid_key->h, &svc_expkey_cache);
1073 1075 return rv;
1074 1076 }
... ... @@ -159,6 +159,7 @@
159 159 detail->update(tmp, new);
160 160 tmp->next = *head;
161 161 *head = tmp;
  162 + detail->entries++;
162 163 cache_get(tmp);
163 164 is_new = cache_fresh_locked(tmp, new->expiry_time);
164 165 cache_fresh_locked(old, 0);