mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev,
	Daniil Tatianin <d-tatianin@yandex-team.ru>,
	"David S. Miller" <davem@davemloft.net>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	netdev@vger.kernel.org,
	Daniil Tatianin <d-tatianin@yandex-team.ru>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Varun Prakash <varun@chelsio.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Mike Christie <michael.christie@oracle.com>,
	Lee Duncan <lduncan@suse.com>, Wu Bo <wubo40@huawei.com>,
	Nilesh Javali <njavali@marvell.com>,
	Max Gurtovoy <mgurtovoy@nvidia.com>,
	linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
	target-devel@vger.kernel.org
Subject: Re: [RESEND PATCH v2] cxgbi: move cxgbi_ddp_set_one_ppod to cxgb_ppm and remove its duplicate
Date: Thu, 29 Dec 2022 16:53:37 +0300	[thread overview]
Message-ID: <202212291705.id5qvdk7-lkp@intel.com> (raw)
In-Reply-To: <20221226090609.1917788-1-d-tatianin@yandex-team.ru>

Hi Daniil,

https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniil-Tatianin/cxgbi-move-cxgbi_ddp_set_one_ppod-to-cxgb_ppm-and-remove-its-duplicate/20221226-171028
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link:    https://lore.kernel.org/r/20221226090609.1917788-1-d-tatianin%40yandex-team.ru
patch subject: [RESEND PATCH v2] cxgbi: move cxgbi_ddp_set_one_ppod to cxgb_ppm and remove its duplicate
config: powerpc-randconfig-m031-20221226
compiler: powerpc-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>

smatch warnings:
drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c:571 cxgbi_ppm_set_one_ppod() error: we previously assumed 'sg_off' could be null (see line 536)

vim +/sg_off +571 drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c

e775e542c914b4 Daniil Tatianin 2022-12-26  530  void
e775e542c914b4 Daniil Tatianin 2022-12-26  531  cxgbi_ppm_set_one_ppod(struct cxgbi_pagepod *ppod,
e775e542c914b4 Daniil Tatianin 2022-12-26  532  		       struct cxgbi_task_tag_info *ttinfo,
e775e542c914b4 Daniil Tatianin 2022-12-26  533  		       struct scatterlist **sg_pp, unsigned int *sg_off)
e775e542c914b4 Daniil Tatianin 2022-12-26  534  {
e775e542c914b4 Daniil Tatianin 2022-12-26  535  	struct scatterlist *sg = sg_pp ? *sg_pp : NULL;
e775e542c914b4 Daniil Tatianin 2022-12-26 @536  	unsigned int offset = sg_off ? *sg_off : 0;
                                                                              ^^^^^^
Check for NULL

e775e542c914b4 Daniil Tatianin 2022-12-26  537  	dma_addr_t addr = 0UL;
e775e542c914b4 Daniil Tatianin 2022-12-26  538  	unsigned int len = 0;
e775e542c914b4 Daniil Tatianin 2022-12-26  539  	int i;
e775e542c914b4 Daniil Tatianin 2022-12-26  540  
e775e542c914b4 Daniil Tatianin 2022-12-26  541  	memcpy(ppod, &ttinfo->hdr, sizeof(struct cxgbi_pagepod_hdr));
e775e542c914b4 Daniil Tatianin 2022-12-26  542  
e775e542c914b4 Daniil Tatianin 2022-12-26  543  	if (sg) {
e775e542c914b4 Daniil Tatianin 2022-12-26  544  		addr = sg_dma_address(sg);
e775e542c914b4 Daniil Tatianin 2022-12-26  545  		len = sg_dma_len(sg);
e775e542c914b4 Daniil Tatianin 2022-12-26  546  	}
e775e542c914b4 Daniil Tatianin 2022-12-26  547  
e775e542c914b4 Daniil Tatianin 2022-12-26  548  	for (i = 0; i < PPOD_PAGES_MAX; i++) {
e775e542c914b4 Daniil Tatianin 2022-12-26  549  		if (sg) {
e775e542c914b4 Daniil Tatianin 2022-12-26  550  			ppod->addr[i] = cpu_to_be64(addr + offset);
e775e542c914b4 Daniil Tatianin 2022-12-26  551  			offset += PAGE_SIZE;
e775e542c914b4 Daniil Tatianin 2022-12-26  552  			if (offset == (len + sg->offset)) {
e775e542c914b4 Daniil Tatianin 2022-12-26  553  				offset = 0;
e775e542c914b4 Daniil Tatianin 2022-12-26  554  				sg = sg_next(sg);
e775e542c914b4 Daniil Tatianin 2022-12-26  555  				if (sg) {
e775e542c914b4 Daniil Tatianin 2022-12-26  556  					addr = sg_dma_address(sg);
e775e542c914b4 Daniil Tatianin 2022-12-26  557  					len = sg_dma_len(sg);
e775e542c914b4 Daniil Tatianin 2022-12-26  558  				}
e775e542c914b4 Daniil Tatianin 2022-12-26  559  			}
e775e542c914b4 Daniil Tatianin 2022-12-26  560  		} else {
e775e542c914b4 Daniil Tatianin 2022-12-26  561  			ppod->addr[i] = 0ULL;
e775e542c914b4 Daniil Tatianin 2022-12-26  562  		}
e775e542c914b4 Daniil Tatianin 2022-12-26  563  	}
e775e542c914b4 Daniil Tatianin 2022-12-26  564  
e775e542c914b4 Daniil Tatianin 2022-12-26  565  	/*
e775e542c914b4 Daniil Tatianin 2022-12-26  566  	 * the fifth address needs to be repeated in the next ppod, so do
e775e542c914b4 Daniil Tatianin 2022-12-26  567  	 * not move sg
e775e542c914b4 Daniil Tatianin 2022-12-26  568  	 */
e775e542c914b4 Daniil Tatianin 2022-12-26  569  	if (sg_pp) {
e775e542c914b4 Daniil Tatianin 2022-12-26  570  		*sg_pp = sg;
e775e542c914b4 Daniil Tatianin 2022-12-26 @571  		*sg_off = offset;
                                                                ^^^^^^^
Unchecked dereference.

e775e542c914b4 Daniil Tatianin 2022-12-26  572  	}
e775e542c914b4 Daniil Tatianin 2022-12-26  573  
e775e542c914b4 Daniil Tatianin 2022-12-26  574  	if (offset == len) {
e775e542c914b4 Daniil Tatianin 2022-12-26  575  		offset = 0;
e775e542c914b4 Daniil Tatianin 2022-12-26  576  		if (sg) {
e775e542c914b4 Daniil Tatianin 2022-12-26  577  			sg = sg_next(sg);
e775e542c914b4 Daniil Tatianin 2022-12-26  578  			if (sg)
e775e542c914b4 Daniil Tatianin 2022-12-26  579  				addr = sg_dma_address(sg);
e775e542c914b4 Daniil Tatianin 2022-12-26  580  		}
e775e542c914b4 Daniil Tatianin 2022-12-26  581  	}
e775e542c914b4 Daniil Tatianin 2022-12-26  582  	ppod->addr[i] = sg ? cpu_to_be64(addr + offset) : 0ULL;
e775e542c914b4 Daniil Tatianin 2022-12-26  583  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp


      reply	other threads:[~2022-12-29 13:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26  9:06 Daniil Tatianin
2022-12-29 13:53 ` Dan Carpenter [this message]

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=202212291705.id5qvdk7-lkp@intel.com \
    --to=error27@gmail.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jejb@linux.ibm.com \
    --cc=kuba@kernel.org \
    --cc=lduncan@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=martin.petersen@oracle.com \
    --cc=mgurtovoy@nvidia.com \
    --cc=michael.christie@oracle.com \
    --cc=netdev@vger.kernel.org \
    --cc=njavali@marvell.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=target-devel@vger.kernel.org \
    --cc=varun@chelsio.com \
    --cc=wubo40@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®