* [bug report] SUNRPC: Simplify lookup code
@ 2018-12-13 14:12 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2018-12-13 14:12 UTC (permalink / raw)
To: trond.myklebust; +Cc: linux-nfs
Hello Trond Myklebust,
The patch 07d02a67b7fa: "SUNRPC: Simplify lookup code" from Oct 12,
2018, leads to the following static checker warning:
net/sunrpc/auth_generic.c:248 generic_key_timeout()
warn: 'tcred' can also be NULL
net/sunrpc/auth_generic.c
238 /* Fast track for the normal case */
239 if (test_bit(RPC_CRED_NOTIFY_TIMEOUT, &acred->ac_flags))
240 return 0;
241
242 /* lookup_cred either returns a valid referenced rpc_cred, or PTR_ERR */
243 tcred = auth->au_ops->lookup_cred(auth, acred, 0);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
244 if (IS_ERR(tcred))
245 return -EACCES;
246
247 /* Test for the almost error case */
248 ret = tcred->cr_ops->crkey_timeout(tcred);
249 if (ret != 0) {
250 set_bit(RPC_CRED_KEY_EXPIRE_SOON, &acred->ac_flags);
251 ret = 0;
252 } else {
The proble is nul_lookup_cred() returns get_rpccred(). It used to be
that get_rpccred() would only return NULL if we passed it a NULL but now
we return NULL if refcount_inc_not_zero() returns zero. In other words
it maybe should be something like:
static inline
struct rpc_cred *get_rpccred(struct rpc_cred *cred)
{
if (!cred)
return NULL;
if (refcount_inc_not_zero(&cred->cr_count))
return cred;
return -EACCES;
}
regards,
dan carpenter
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-12-13 14:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-13 14:12 [bug report] SUNRPC: Simplify lookup code Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox