Re: [PATCH 03/16] lpfc: Fix reference counting errors in lpfc_cmpl_els_rsp()

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

 



Hi James,

I love your patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on mkp-scsi/for-next linus/master v5.12-rc6 next-20210409]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/James-Smart/lpfc-Update-lpfc-to-revision-12-8-0-9/20210411-013122
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: x86_64-allyesconfig (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
        # https://github.com/0day-ci/linux/commit/14cc4aacd0b5890c9db3ce319c67b956520a2aa7
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review James-Smart/lpfc-Update-lpfc-to-revision-12-8-0-9/20210411-013122
        git checkout 14cc4aacd0b5890c9db3ce319c67b956520a2aa7
        # save the attached .config to linux build tree
        make W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

   drivers/scsi/lpfc/lpfc_els.c: In function 'lpfc_cmpl_els_rsp':
>> drivers/scsi/lpfc/lpfc_els.c:4460:11: warning: variable 'ls_rjt' set but not used [-Wunused-but-set-variable]
    4460 |  uint32_t ls_rjt = 0;
         |           ^~~~~~


vim +/ls_rjt +4460 drivers/scsi/lpfc/lpfc_els.c

858c9f6c19c6f9 James Smart     2007-06-17  4435  
e59058c44025d7 James Smart     2008-08-24  4436  /**
3621a710a7dbb2 James Smart     2009-04-06  4437   * lpfc_cmpl_els_rsp - Completion callback function for els response iocb cmd
e59058c44025d7 James Smart     2008-08-24  4438   * @phba: pointer to lpfc hba data structure.
e59058c44025d7 James Smart     2008-08-24  4439   * @cmdiocb: pointer to lpfc command iocb data structure.
e59058c44025d7 James Smart     2008-08-24  4440   * @rspiocb: pointer to lpfc response iocb data structure.
e59058c44025d7 James Smart     2008-08-24  4441   *
e59058c44025d7 James Smart     2008-08-24  4442   * This routine is the completion callback function for ELS Response IOCB
e59058c44025d7 James Smart     2008-08-24  4443   * command. In normal case, this callback function just properly sets the
e59058c44025d7 James Smart     2008-08-24  4444   * nlp_flag bitmap in the ndlp data structure, if the mbox command reference
e59058c44025d7 James Smart     2008-08-24  4445   * field in the command IOCB is not NULL, the referred mailbox command will
e59058c44025d7 James Smart     2008-08-24  4446   * be send out, and then invokes the lpfc_els_free_iocb() routine to release
14cc4aacd0b589 James Smart     2021-04-10  4447   * the IOCB.
e59058c44025d7 James Smart     2008-08-24  4448   **/
dea3101e0a5c89 James Bottomley 2005-04-17  4449  static void
858c9f6c19c6f9 James Smart     2007-06-17  4450  lpfc_cmpl_els_rsp(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,
dea3101e0a5c89 James Bottomley 2005-04-17  4451  		  struct lpfc_iocbq *rspiocb)
dea3101e0a5c89 James Bottomley 2005-04-17  4452  {
2e0fef85e098f6 James Smart     2007-06-17  4453  	struct lpfc_nodelist *ndlp = (struct lpfc_nodelist *) cmdiocb->context1;
2e0fef85e098f6 James Smart     2007-06-17  4454  	struct lpfc_vport *vport = ndlp ? ndlp->vport : NULL;
2e0fef85e098f6 James Smart     2007-06-17  4455  	struct Scsi_Host  *shost = vport ? lpfc_shost_from_vport(vport) : NULL;
33ccf8d1080bdc James Smart     2006-08-17  4456  	IOCB_t  *irsp;
87af33fe5f78c2 James Smart     2007-10-27  4457  	uint8_t *pcmd;
dea3101e0a5c89 James Bottomley 2005-04-17  4458  	LPFC_MBOXQ_t *mbox = NULL;
2e0fef85e098f6 James Smart     2007-06-17  4459  	struct lpfc_dmabuf *mp = NULL;
87af33fe5f78c2 James Smart     2007-10-27 @4460  	uint32_t ls_rjt = 0;
dea3101e0a5c89 James Bottomley 2005-04-17  4461  
33ccf8d1080bdc James Smart     2006-08-17  4462  	irsp = &rspiocb->iocb;
33ccf8d1080bdc James Smart     2006-08-17  4463  
43bfea1bffb6b0 James Smart     2019-09-21  4464  	if (!vport) {
372c187b8a705c Dick Kennedy    2020-06-30  4465  		lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
43bfea1bffb6b0 James Smart     2019-09-21  4466  				"3177 ELS response failed\n");
43bfea1bffb6b0 James Smart     2019-09-21  4467  		goto out;
43bfea1bffb6b0 James Smart     2019-09-21  4468  	}
dea3101e0a5c89 James Bottomley 2005-04-17  4469  	if (cmdiocb->context_un.mbox)
dea3101e0a5c89 James Bottomley 2005-04-17  4470  		mbox = cmdiocb->context_un.mbox;
dea3101e0a5c89 James Bottomley 2005-04-17  4471  
fa4066b672821d James Smart     2008-01-11  4472  	/* First determine if this is a LS_RJT cmpl. Note, this callback
fa4066b672821d James Smart     2008-01-11  4473  	 * function can have cmdiocb->contest1 (ndlp) field set to NULL.
fa4066b672821d James Smart     2008-01-11  4474  	 */
87af33fe5f78c2 James Smart     2007-10-27  4475  	pcmd = (uint8_t *) (((struct lpfc_dmabuf *) cmdiocb->context2)->virt);
307e338097dc32 James Smart     2020-11-15  4476  	if (ndlp && (*((uint32_t *) (pcmd)) == ELS_CMD_LS_RJT)) {
fa4066b672821d James Smart     2008-01-11  4477  		/* A LS_RJT associated with Default RPI cleanup has its own
3ad2f3fbb96142 Daniel Mack     2010-02-03  4478  		 * separate code path.
87af33fe5f78c2 James Smart     2007-10-27  4479  		 */
87af33fe5f78c2 James Smart     2007-10-27  4480  		if (!(ndlp->nlp_flag & NLP_RM_DFLT_RPI))
87af33fe5f78c2 James Smart     2007-10-27  4481  			ls_rjt = 1;
87af33fe5f78c2 James Smart     2007-10-27  4482  	}
87af33fe5f78c2 James Smart     2007-10-27  4483  
dea3101e0a5c89 James Bottomley 2005-04-17  4484  	/* Check to see if link went down during discovery */
307e338097dc32 James Smart     2020-11-15  4485  	if (!ndlp || lpfc_els_chk_latt(vport)) {
dea3101e0a5c89 James Bottomley 2005-04-17  4486  		if (mbox) {
3e1f0718921cd1 James Smart     2018-11-29  4487  			mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
146911500f2572 James Smart     2006-12-02  4488  			if (mp) {
146911500f2572 James Smart     2006-12-02  4489  				lpfc_mbuf_free(phba, mp->virt, mp->phys);
146911500f2572 James Smart     2006-12-02  4490  				kfree(mp);
146911500f2572 James Smart     2006-12-02  4491  			}
dea3101e0a5c89 James Bottomley 2005-04-17  4492  			mempool_free(mbox, phba->mbox_mem_pool);
dea3101e0a5c89 James Bottomley 2005-04-17  4493  		}
dea3101e0a5c89 James Bottomley 2005-04-17  4494  		goto out;
dea3101e0a5c89 James Bottomley 2005-04-17  4495  	}
dea3101e0a5c89 James Bottomley 2005-04-17  4496  
858c9f6c19c6f9 James Smart     2007-06-17  4497  	lpfc_debugfs_disc_trc(vport, LPFC_DISC_TRC_ELS_RSP,
51ef4c26891a73 James Smart     2007-08-02  4498  		"ELS rsp cmpl:    status:x%x/x%x did:x%x",
858c9f6c19c6f9 James Smart     2007-06-17  4499  		irsp->ulpStatus, irsp->un.ulpWord[4],
51ef4c26891a73 James Smart     2007-08-02  4500  		cmdiocb->iocb.un.elsreq64.remoteID);
dea3101e0a5c89 James Bottomley 2005-04-17  4501  	/* ELS response tag <ulpIoTag> completes */
e8b62011d88d6f James Smart     2007-08-02  4502  	lpfc_printf_vlog(vport, KERN_INFO, LOG_ELS,
e8b62011d88d6f James Smart     2007-08-02  4503  			 "0110 ELS response tag x%x completes "
c9f8735beadfba Jamie Wellnitz  2006-02-28  4504  			 "Data: x%x x%x x%x x%x x%x x%x x%x\n",
dea3101e0a5c89 James Bottomley 2005-04-17  4505  			 cmdiocb->iocb.ulpIoTag, rspiocb->iocb.ulpStatus,
c9f8735beadfba Jamie Wellnitz  2006-02-28  4506  			 rspiocb->iocb.un.ulpWord[4], rspiocb->iocb.ulpTimeout,
c9f8735beadfba Jamie Wellnitz  2006-02-28  4507  			 ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
c9f8735beadfba Jamie Wellnitz  2006-02-28  4508  			 ndlp->nlp_rpi);
dea3101e0a5c89 James Bottomley 2005-04-17  4509  	if (mbox) {
4430f7fd09ecb0 James Smart     2020-11-15  4510  		if ((rspiocb->iocb.ulpStatus == 0) &&
4430f7fd09ecb0 James Smart     2020-11-15  4511  		    (ndlp->nlp_flag & NLP_ACC_REGLOGIN)) {
1fe68477d235e4 Dick Kennedy    2017-08-23  4512  			if (!lpfc_unreg_rpi(vport, ndlp) &&
4430f7fd09ecb0 James Smart     2020-11-15  4513  			    (!(vport->fc_flag & FC_PT2PT))) {
4430f7fd09ecb0 James Smart     2020-11-15  4514  				if (ndlp->nlp_state == NLP_STE_REG_LOGIN_ISSUE) {
1fe68477d235e4 Dick Kennedy    2017-08-23  4515  					lpfc_printf_vlog(vport, KERN_INFO,
1fe68477d235e4 Dick Kennedy    2017-08-23  4516  							 LOG_DISCOVERY,
4430f7fd09ecb0 James Smart     2020-11-15  4517  							 "0314 PLOGI recov "
4430f7fd09ecb0 James Smart     2020-11-15  4518  							 "DID x%x "
1fe68477d235e4 Dick Kennedy    2017-08-23  4519  							 "Data: x%x x%x x%x\n",
4430f7fd09ecb0 James Smart     2020-11-15  4520  							 ndlp->nlp_DID,
4430f7fd09ecb0 James Smart     2020-11-15  4521  							 ndlp->nlp_state,
4430f7fd09ecb0 James Smart     2020-11-15  4522  							 ndlp->nlp_rpi,
4430f7fd09ecb0 James Smart     2020-11-15  4523  							 ndlp->nlp_flag);
3e1f0718921cd1 James Smart     2018-11-29  4524  					mp = mbox->ctx_buf;
1fe68477d235e4 Dick Kennedy    2017-08-23  4525  					if (mp) {
1fe68477d235e4 Dick Kennedy    2017-08-23  4526  						lpfc_mbuf_free(phba, mp->virt,
1fe68477d235e4 Dick Kennedy    2017-08-23  4527  							       mp->phys);
1fe68477d235e4 Dick Kennedy    2017-08-23  4528  						kfree(mp);
1fe68477d235e4 Dick Kennedy    2017-08-23  4529  					}
1fe68477d235e4 Dick Kennedy    2017-08-23  4530  					mempool_free(mbox, phba->mbox_mem_pool);
1fe68477d235e4 Dick Kennedy    2017-08-23  4531  					goto out;
1fe68477d235e4 Dick Kennedy    2017-08-23  4532  				}
4430f7fd09ecb0 James Smart     2020-11-15  4533  			}
1fe68477d235e4 Dick Kennedy    2017-08-23  4534  
e47c9093531d34 James Smart     2008-02-08  4535  			/* Increment reference count to ndlp to hold the
e47c9093531d34 James Smart     2008-02-08  4536  			 * reference to ndlp for the callback function.
e47c9093531d34 James Smart     2008-02-08  4537  			 */
3e1f0718921cd1 James Smart     2018-11-29  4538  			mbox->ctx_ndlp = lpfc_nlp_get(ndlp);
4430f7fd09ecb0 James Smart     2020-11-15  4539  			if (!mbox->ctx_ndlp)
4430f7fd09ecb0 James Smart     2020-11-15  4540  				goto out;
4430f7fd09ecb0 James Smart     2020-11-15  4541  
2e0fef85e098f6 James Smart     2007-06-17  4542  			mbox->vport = vport;
858c9f6c19c6f9 James Smart     2007-06-17  4543  			if (ndlp->nlp_flag & NLP_RM_DFLT_RPI) {
858c9f6c19c6f9 James Smart     2007-06-17  4544  				mbox->mbox_flag |= LPFC_MBX_IMED_UNREG;
858c9f6c19c6f9 James Smart     2007-06-17  4545  				mbox->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi;
858c9f6c19c6f9 James Smart     2007-06-17  4546  			}
858c9f6c19c6f9 James Smart     2007-06-17  4547  			else {
858c9f6c19c6f9 James Smart     2007-06-17  4548  				mbox->mbox_cmpl = lpfc_mbx_cmpl_reg_login;
5024ab179c13d7 Jamie Wellnitz  2006-02-28  4549  				ndlp->nlp_prev_state = ndlp->nlp_state;
2e0fef85e098f6 James Smart     2007-06-17  4550  				lpfc_nlp_set_state(vport, ndlp,
2e0fef85e098f6 James Smart     2007-06-17  4551  					   NLP_STE_REG_LOGIN_ISSUE);
858c9f6c19c6f9 James Smart     2007-06-17  4552  			}
4b7789b71c916f James Smart     2015-12-16  4553  
4b7789b71c916f James Smart     2015-12-16  4554  			ndlp->nlp_flag |= NLP_REG_LOGIN_SEND;
0b727fea7a700e James Smart     2007-10-27  4555  			if (lpfc_sli_issue_mbox(phba, mbox, MBX_NOWAIT)
e47c9093531d34 James Smart     2008-02-08  4556  			    != MBX_NOT_FINISHED)
dea3101e0a5c89 James Bottomley 2005-04-17  4557  				goto out;
4b7789b71c916f James Smart     2015-12-16  4558  
e47c9093531d34 James Smart     2008-02-08  4559  			/* Decrement the ndlp reference count we
e47c9093531d34 James Smart     2008-02-08  4560  			 * set for this failed mailbox command.
e47c9093531d34 James Smart     2008-02-08  4561  			 */
e47c9093531d34 James Smart     2008-02-08  4562  			lpfc_nlp_put(ndlp);
4b7789b71c916f James Smart     2015-12-16  4563  			ndlp->nlp_flag &= ~NLP_REG_LOGIN_SEND;
98c9ea5c026ee4 James Smart     2007-10-27  4564  
98c9ea5c026ee4 James Smart     2007-10-27  4565  			/* ELS rsp: Cannot issue reg_login for <NPortid> */
372c187b8a705c Dick Kennedy    2020-06-30  4566  			lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT,
98c9ea5c026ee4 James Smart     2007-10-27  4567  				"0138 ELS rsp: Cannot issue reg_login for x%x "
98c9ea5c026ee4 James Smart     2007-10-27  4568  				"Data: x%x x%x x%x\n",
98c9ea5c026ee4 James Smart     2007-10-27  4569  				ndlp->nlp_DID, ndlp->nlp_flag, ndlp->nlp_state,
98c9ea5c026ee4 James Smart     2007-10-27  4570  				ndlp->nlp_rpi);
dea3101e0a5c89 James Bottomley 2005-04-17  4571  		}
3e1f0718921cd1 James Smart     2018-11-29  4572  		mp = (struct lpfc_dmabuf *)mbox->ctx_buf;
146911500f2572 James Smart     2006-12-02  4573  		if (mp) {
146911500f2572 James Smart     2006-12-02  4574  			lpfc_mbuf_free(phba, mp->virt, mp->phys);
146911500f2572 James Smart     2006-12-02  4575  			kfree(mp);
146911500f2572 James Smart     2006-12-02  4576  		}
146911500f2572 James Smart     2006-12-02  4577  		mempool_free(mbox, phba->mbox_mem_pool);
33ccf8d1080bdc James Smart     2006-08-17  4578  	}
dea3101e0a5c89 James Bottomley 2005-04-17  4579  out:
307e338097dc32 James Smart     2020-11-15  4580  	if (ndlp && shost) {
c6adba15019176 James Smart     2020-11-15  4581  		spin_lock_irq(&ndlp->lock);
7b08e89f98cee9 James Smart     2020-08-28  4582  		if (mbox)
7b08e89f98cee9 James Smart     2020-08-28  4583  			ndlp->nlp_flag &= ~NLP_ACC_REGLOGIN;
7b08e89f98cee9 James Smart     2020-08-28  4584  		ndlp->nlp_flag &= ~NLP_RM_DFLT_RPI;
c6adba15019176 James Smart     2020-11-15  4585  		spin_unlock_irq(&ndlp->lock);
dea3101e0a5c89 James Bottomley 2005-04-17  4586  	}
87af33fe5f78c2 James Smart     2007-10-27  4587  
4430f7fd09ecb0 James Smart     2020-11-15  4588  	/* Release the originating I/O reference. */
dea3101e0a5c89 James Bottomley 2005-04-17  4589  	lpfc_els_free_iocb(phba, cmdiocb);
4430f7fd09ecb0 James Smart     2020-11-15  4590  	lpfc_nlp_put(ndlp);
dea3101e0a5c89 James Bottomley 2005-04-17  4591  	return;
dea3101e0a5c89 James Bottomley 2005-04-17  4592  }
dea3101e0a5c89 James Bottomley 2005-04-17  4593  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux