Skip to contentSkip to conversation

knfsd: Fix two problems that can cause rmmod nfsd to die.

PATCH New NeilBrown 1 participant 1 message May 22, 2006 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20060522111746.2437.patches@notabene

NeilBrown

author
#1 lore raw

PATCH 1/1 knfsd: Fix two problems that can cause rmmod nfsd to die.

This patch applies to -mm and current -git and should go to Linus before 2.6.17
Thanks.
NeilBrown

### Comments for Changeset

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" <[email protected]> for triggering the problem and finding one of the bugs.

Cc "david m. richter" <[email protected]>

### Diffstat output

 ./fs/nfsd/export.c   |    4 +++-
 ./net/sunrpc/cache.c |    1 +
 2 files changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/export.c renamed from fs/nfsd/export.c~current~ +3 -1
diff ./fs/nfsd/export.c~current~ ./fs/nfsd/export.c
@@ -1066,9 +1066,11 @@ exp_pseudoroot(struct auth_domain *clp, 
 		rv = nfserr_perm;
 	else if (IS_ERR(exp))
 		rv = nfserrno(PTR_ERR(exp));
-	else
+	else {
 		rv = fh_compose(fhp, exp,
 				fsid_key->ek_dentry, NULL);
+		exp_put(exp);
+	}
 	cache_put(&fsid_key->h, &svc_expkey_cache);
 	return rv;
 }
net/sunrpc/cache.c renamed from net/sunrpc/cache.c~current~ +1 -0
diff ./net/sunrpc/cache.c~current~ ./net/sunrpc/cache.c
@@ -159,6 +159,7 @@ struct cache_head *sunrpc_cache_update(s
 		detail->update(tmp, new);
 	tmp->next = *head;
 	*head = tmp;
+	detail->entries++;
 	cache_get(tmp);
 	is_new = cache_fresh_locked(tmp, new->expiry_time);
 	cache_fresh_locked(old, 0);