All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: fs/nfsd/nfs4state.c:5708 manage_cpntf_state() warn: can 'state' even be NULL?
Date: Sun, 3 Dec 2023 14:32:11 +0800	[thread overview]
Message-ID: <202312031425.LffZTarR-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Olga Kornievskaia <kolga@netapp.com>
CC: "J. Bruce Fields" <bfields@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   968f35f4ab1c0966ceb39af3c89f2e24afedf878
commit: ce0887ac96d35c7105090e166bb0807dc0a0e838 NFSD add nfs4 inter ssc to nfsd4_copy
date:   4 years ago
:::::: branch date: 6 hours ago
:::::: commit date: 4 years ago
config: i386-randconfig-141-20231010 (https://download.01.org/0day-ci/archive/20231203/202312031425.LffZTarR-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231203/202312031425.LffZTarR-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202312031425.LffZTarR-lkp@intel.com/

smatch warnings:
fs/nfsd/nfs4state.c:5708 manage_cpntf_state() warn: can 'state' even be NULL?

vim +/state +5708 fs/nfsd/nfs4state.c

a0649b2d3fffb1 Christoph Hellwig 2015-06-18  5642  
af90f707fa6d54 Christoph Hellwig 2015-06-18  5643  static __be32
af90f707fa6d54 Christoph Hellwig 2015-06-18  5644  nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s,
5c4583b2b78eef Jeff Layton       2019-08-18  5645  		struct nfsd_file **nfp, int flags)
af90f707fa6d54 Christoph Hellwig 2015-06-18  5646  {
af90f707fa6d54 Christoph Hellwig 2015-06-18  5647  	int acc = (flags & RD_STATE) ? NFSD_MAY_READ : NFSD_MAY_WRITE;
eb82dd39374410 Jeff Layton       2019-08-18  5648  	struct nfsd_file *nf;
af90f707fa6d54 Christoph Hellwig 2015-06-18  5649  	__be32 status;
af90f707fa6d54 Christoph Hellwig 2015-06-18  5650  
eb82dd39374410 Jeff Layton       2019-08-18  5651  	nf = nfs4_find_file(s, flags);
eb82dd39374410 Jeff Layton       2019-08-18  5652  	if (nf) {
af90f707fa6d54 Christoph Hellwig 2015-06-18  5653  		status = nfsd_permission(rqstp, fhp->fh_export, fhp->fh_dentry,
af90f707fa6d54 Christoph Hellwig 2015-06-18  5654  				acc | NFSD_MAY_OWNER_OVERRIDE);
5c4583b2b78eef Jeff Layton       2019-08-18  5655  		if (status) {
5c4583b2b78eef Jeff Layton       2019-08-18  5656  			nfsd_file_put(nf);
eb82dd39374410 Jeff Layton       2019-08-18  5657  			goto out;
5c4583b2b78eef Jeff Layton       2019-08-18  5658  		}
af90f707fa6d54 Christoph Hellwig 2015-06-18  5659  	} else {
eb82dd39374410 Jeff Layton       2019-08-18  5660  		status = nfsd_file_acquire(rqstp, fhp, acc, &nf);
af90f707fa6d54 Christoph Hellwig 2015-06-18  5661  		if (status)
af90f707fa6d54 Christoph Hellwig 2015-06-18  5662  			return status;
af90f707fa6d54 Christoph Hellwig 2015-06-18  5663  	}
5c4583b2b78eef Jeff Layton       2019-08-18  5664  	*nfp = nf;
eb82dd39374410 Jeff Layton       2019-08-18  5665  out:
eb82dd39374410 Jeff Layton       2019-08-18  5666  	return status;
af90f707fa6d54 Christoph Hellwig 2015-06-18  5667  }
624322f1adc58a Olga Kornievskaia 2019-10-04  5668  static void
624322f1adc58a Olga Kornievskaia 2019-10-04  5669  _free_cpntf_state_locked(struct nfsd_net *nn, struct nfs4_cpntf_state *cps)
624322f1adc58a Olga Kornievskaia 2019-10-04  5670  {
624322f1adc58a Olga Kornievskaia 2019-10-04  5671  	WARN_ON_ONCE(cps->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID);
624322f1adc58a Olga Kornievskaia 2019-10-04  5672  	if (!refcount_dec_and_test(&cps->cp_stateid.sc_count))
624322f1adc58a Olga Kornievskaia 2019-10-04  5673  		return;
624322f1adc58a Olga Kornievskaia 2019-10-04  5674  	list_del(&cps->cp_list);
624322f1adc58a Olga Kornievskaia 2019-10-04  5675  	idr_remove(&nn->s2s_cp_stateids,
624322f1adc58a Olga Kornievskaia 2019-10-04  5676  		   cps->cp_stateid.stid.si_opaque.so_id);
624322f1adc58a Olga Kornievskaia 2019-10-04  5677  	kfree(cps);
624322f1adc58a Olga Kornievskaia 2019-10-04  5678  }
b7342204253aaa Olga Kornievskaia 2019-09-06  5679  /*
b7342204253aaa Olga Kornievskaia 2019-09-06  5680   * A READ from an inter server to server COPY will have a
b7342204253aaa Olga Kornievskaia 2019-09-06  5681   * copy stateid. Look up the copy notify stateid from the
b7342204253aaa Olga Kornievskaia 2019-09-06  5682   * idr structure and take a reference on it.
b7342204253aaa Olga Kornievskaia 2019-09-06  5683   */
ce0887ac96d35c Olga Kornievskaia 2019-10-09  5684  __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
ce0887ac96d35c Olga Kornievskaia 2019-10-09  5685  			  struct nfs4_client *clp,
b7342204253aaa Olga Kornievskaia 2019-09-06  5686  			  struct nfs4_cpntf_state **cps)
b7342204253aaa Olga Kornievskaia 2019-09-06  5687  {
b7342204253aaa Olga Kornievskaia 2019-09-06  5688  	copy_stateid_t *cps_t;
b7342204253aaa Olga Kornievskaia 2019-09-06  5689  	struct nfs4_cpntf_state *state = NULL;
b7342204253aaa Olga Kornievskaia 2019-09-06  5690  
b7342204253aaa Olga Kornievskaia 2019-09-06  5691  	if (st->si_opaque.so_clid.cl_id != nn->s2s_cp_cl_id)
b7342204253aaa Olga Kornievskaia 2019-09-06  5692  		return nfserr_bad_stateid;
b7342204253aaa Olga Kornievskaia 2019-09-06  5693  	spin_lock(&nn->s2s_cp_lock);
b7342204253aaa Olga Kornievskaia 2019-09-06  5694  	cps_t = idr_find(&nn->s2s_cp_stateids, st->si_opaque.so_id);
b7342204253aaa Olga Kornievskaia 2019-09-06  5695  	if (cps_t) {
b7342204253aaa Olga Kornievskaia 2019-09-06  5696  		state = container_of(cps_t, struct nfs4_cpntf_state,
b7342204253aaa Olga Kornievskaia 2019-09-06  5697  				     cp_stateid);
b7342204253aaa Olga Kornievskaia 2019-09-06  5698  		if (state->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID)
b7342204253aaa Olga Kornievskaia 2019-09-06  5699  			return nfserr_bad_stateid;
ce0887ac96d35c Olga Kornievskaia 2019-10-09  5700  		if (!clp)
b7342204253aaa Olga Kornievskaia 2019-09-06  5701  			refcount_inc(&state->cp_stateid.sc_count);
ce0887ac96d35c Olga Kornievskaia 2019-10-09  5702  		else
ce0887ac96d35c Olga Kornievskaia 2019-10-09  5703  			_free_cpntf_state_locked(nn, state);
b7342204253aaa Olga Kornievskaia 2019-09-06  5704  	}
b7342204253aaa Olga Kornievskaia 2019-09-06  5705  	spin_unlock(&nn->s2s_cp_lock);
b7342204253aaa Olga Kornievskaia 2019-09-06  5706  	if (!state)
b7342204253aaa Olga Kornievskaia 2019-09-06  5707  		return nfserr_bad_stateid;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 @5708  	if (!clp && state)
b7342204253aaa Olga Kornievskaia 2019-09-06  5709  		*cps = state;
b7342204253aaa Olga Kornievskaia 2019-09-06  5710  	return 0;
b7342204253aaa Olga Kornievskaia 2019-09-06  5711  }
b7342204253aaa Olga Kornievskaia 2019-09-06  5712  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2023-12-03  6:32 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=202312031425.LffZTarR-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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.