[bug report] SUNRPC: Simplify lookup code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux