From: Dan Carpenter <dan.carpenter@oracle.com>
To: trond.myklebust@hammerspace.com
Cc: linux-nfs@vger.kernel.org
Subject: [bug report] SUNRPC: Simplify lookup code
Date: Thu, 13 Dec 2018 17:12:41 +0300 [thread overview]
Message-ID: <20181213141241.GA3971@kadam> (raw)
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
reply other threads:[~2018-12-13 14:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181213141241.GA3971@kadam \
--to=dan.carpenter@oracle.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.