@@ -287,8 +287,10 @@ static int do_cache_lookup(struct cache_detail *cd,
*item = nfs_dns_lookup(cd, key);
if (*item) {
ret = cache_check(cd, &(*item)->h, &dreq->req);
- if (ret)
+ if (ret) {
+ cache_put(&(*item)->h, cd);
*item = NULL;
+ }
}
return ret;
}
@@ -953,6 +953,7 @@ exp_find_key(struct cache_detail *cd, struct auth_domain *clp, int fsid_type,
return ERR_PTR(-ENOMEM);
err = cache_check(cd, &ek->h, reqp);
if (err) {
+ cache_put(&ek->h, cd);
trace_nfsd_exp_find_key(&key, err);
return ERR_PTR(err);
}
@@ -978,6 +979,7 @@ exp_get_by_name(struct cache_detail *cd, struct auth_domain *clp,
return ERR_PTR(-ENOMEM);
err = cache_check(cd, &exp->h, reqp);
if (err) {
+ cache_put(&exp->h, cd);
trace_nfsd_exp_get_by_name(&key, err);
return ERR_PTR(err);
}
@@ -1428,8 +1430,10 @@ static int e_show(struct seq_file *m, void *p)
if (!cache_get_rcu(&exp->h))
return 0;
- if (cache_check(cd, &exp->h, NULL))
+ if (cache_check(cd, &exp->h, NULL)) {
+ cache_put(&exp->h, cd);
return 0;
+ }
exp_put(exp);
return svc_export_show(m, cd, cp);
@@ -515,6 +515,8 @@ idmap_lookup(struct svc_rqst *rqstp,
return -ENOMEM;
retry:
ret = cache_check(detail, &(*item)->h, &rqstp->rq_chandle);
+ if (ret)
+ cache_put(&(*item)->h, detail);
if (ret == -ETIMEDOUT) {
struct ent *prev_item = *item;
@@ -634,8 +634,11 @@ gss_svc_searchbyctx(struct cache_detail *cd, struct xdr_netobj *handle)
rsc_free(&rsci);
if (!found)
return NULL;
- if (cache_check(cd, &found->h, NULL))
+ if (cache_check(cd, &found->h, NULL)) {
+ cache_put(&found->h, cd);
return NULL;
+ }
+
return found;
}
@@ -1194,9 +1197,11 @@ svcauth_gss_legacy_init(struct svc_rqst *rqstp,
rsi_free(&rsikey);
if (!rsip)
return SVC_CLOSE;
- if (cache_check(sn->rsi_cache, &rsip->h, &rqstp->rq_chandle) < 0)
+ if (cache_check(sn->rsi_cache, &rsip->h, &rqstp->rq_chandle) < 0) {
/* No upcall result: */
+ cache_put(&rsip->h, sn->rsi_cache);
return SVC_CLOSE;
+ }
ret = SVC_CLOSE;
if (!svcauth_gss_proc_init_verf(sn->rsc_cache, rqstp, &rsip->out_handle,
@@ -336,8 +336,6 @@ int cache_check(struct cache_detail *detail,
rv = -ETIMEDOUT;
}
}
- if (rv)
- cache_put(h, detail);
return rv;
}
EXPORT_SYMBOL_GPL(cache_check);
@@ -1430,10 +1428,11 @@ static int c_show(struct seq_file *m, void *p)
if (!cache_get_rcu(cp))
return 0;
- if (cache_check(cd, cp, NULL))
+ if (cache_check(cd, cp, NULL)) {
+ cache_put(cp, cd);
/* cache_check does a cache_put on failure */
seq_puts(m, "# ");
- else {
+ } else {
if (cache_is_expired(cd, cp))
seq_puts(m, "# ");
cache_put(cp, cd);
@@ -651,6 +651,10 @@ static struct group_info *unix_gid_find(kuid_t uid, struct svc_rqst *rqstp)
if (!ug)
return ERR_PTR(-EAGAIN);
ret = cache_check(sn->unix_gid_cache, &ug->h, &rqstp->rq_chandle);
+
+ if (ret)
+ cache_put(&ug->h, sn->unix_gid_cache);
+
switch (ret) {
case -ENOENT:
return ERR_PTR(-ENOENT);
@@ -676,6 +680,7 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
struct svc_xprt *xprt = rqstp->rq_xprt;
struct net *net = xprt->xpt_net;
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
+ int check_res;
switch (rqstp->rq_addr.ss_family) {
case AF_INET:
@@ -704,7 +709,12 @@ svcauth_unix_set_client(struct svc_rqst *rqstp)
if (ipm == NULL)
return SVC_DENIED;
- switch (cache_check(sn->ip_map_cache, &ipm->h, &rqstp->rq_chandle)) {
+ check_res = cache_check(sn->ip_map_cache, &ipm->h, &rqstp->rq_chandle);
+
+ if (check_res)
+ cache_put(&ipm->h, sn->ip_map_cache);
+
+ switch (check_res) {
default:
BUG();
case -ETIMEDOUT: