public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Dan Carpenter <dan.carpenter@linaro.org>,
	oe-kbuild@lists.linux.dev, bhelgaas@google.com
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: optimize proc sequential file read
Date: Tue, 22 Oct 2024 09:54:32 +0800	[thread overview]
Message-ID: <56519e26-029d-46a1-b7cf-9391775da5bc@linux.alibaba.com> (raw)
In-Reply-To: <206eef75-bd2b-43ef-a324-6556c47c9b93@stanley.mountain>


在 2024/10/21 15:17, Dan Carpenter 写道:
> Hi Guixin,
>
> kernel test robot noticed the following build warnings:
>
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url:    https://github.com/intel-lab-lkp/linux/commits/Guixin-Liu/PCI-optimize-proc-sequential-file-read/20241018-135026
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
> patch link:    https://lore.kernel.org/r/20241018054728.116519-1-kanie%40linux.alibaba.com
> patch subject: [PATCH] PCI: optimize proc sequential file read
> config: i386-randconfig-141-20241019 (https://download.01.org/0day-ci/archive/20241019/202410190659.9MCI8EyL-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
>
> 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 <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202410190659.9MCI8EyL-lkp@intel.com/
>
> smatch warnings:
> drivers/pci/proc.c:365 pci_seq_tree_remove_dev() warn: variable dereferenced before check 'dev' (see line 361)
>
> vim +/dev +365 drivers/pci/proc.c
>
> 4ca256d9a0e58a Guixin Liu 2024-10-18  359  void pci_seq_tree_remove_dev(struct pci_dev *dev)
> 4ca256d9a0e58a Guixin Liu 2024-10-18  360  {
> 4ca256d9a0e58a Guixin Liu 2024-10-18 @361  	unsigned long idx = dev->proc_seq_idx;
>                                                                      ^^^^^^^^^^^^^^^^^
> Dereferenced

Thanks, changed in v2.

Best Regards,

Guixin Liu

> 4ca256d9a0e58a Guixin Liu 2024-10-18  362  	struct pci_dev *latest_dev = NULL;
> 4ca256d9a0e58a Guixin Liu 2024-10-18  363  	struct pci_dev *ret;
> 4ca256d9a0e58a Guixin Liu 2024-10-18  364
> 4ca256d9a0e58a Guixin Liu 2024-10-18 @365  	if (!dev)
>                                                      ^^^^
> Checked too late
>
> 4ca256d9a0e58a Guixin Liu 2024-10-18  366  		return;
> 4ca256d9a0e58a Guixin Liu 2024-10-18  367
> 4ca256d9a0e58a Guixin Liu 2024-10-18  368  	xa_lock(&pci_seq_tree);
> 4ca256d9a0e58a Guixin Liu 2024-10-18  369  	__xa_erase(&pci_seq_tree, idx);
> 4ca256d9a0e58a Guixin Liu 2024-10-18  370  	pci_dev_put(dev);
> 4ca256d9a0e58a Guixin Liu 2024-10-18  371  	/*
> 4ca256d9a0e58a Guixin Liu 2024-10-18  372  	 * Move the latest pci_dev to this idx to keep the continuity.
> 4ca256d9a0e58a Guixin Liu 2024-10-18  373  	 */
> 4ca256d9a0e58a Guixin Liu 2024-10-18  374  	if (idx != pci_max_idx - 1) {
> 4ca256d9a0e58a Guixin Liu 2024-10-18  375  		latest_dev = __xa_erase(&pci_seq_tree, pci_max_idx - 1);
> 4ca256d9a0e58a Guixin Liu 2024-10-18  376  		ret = __xa_cmpxchg(&pci_seq_tree, idx, NULL, latest_dev,
> 4ca256d9a0e58a Guixin Liu 2024-10-18  377  				GFP_KERNEL);
> 4ca256d9a0e58a Guixin Liu 2024-10-18  378  		if (!ret)
> 4ca256d9a0e58a Guixin Liu 2024-10-18  379  			latest_dev->proc_seq_idx = idx;
> 4ca256d9a0e58a Guixin Liu 2024-10-18  380  		WARN_ON(ret);
> 4ca256d9a0e58a Guixin Liu 2024-10-18  381  	}
> 4ca256d9a0e58a Guixin Liu 2024-10-18  382  	pci_max_idx--;
> 4ca256d9a0e58a Guixin Liu 2024-10-18  383  	xa_unlock(&pci_seq_tree);
> 4ca256d9a0e58a Guixin Liu 2024-10-18  384  }
>

  reply	other threads:[~2024-10-22  1:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18  5:47 [PATCH] PCI: optimize proc sequential file read Guixin Liu
2024-10-18 22:22 ` Bjorn Helgaas
2024-10-21  2:04   ` Guixin Liu
2024-10-21 11:04     ` Greg KH
2024-10-22  2:21       ` Guixin Liu
2024-10-19  6:39 ` kernel test robot
2024-10-19 18:41 ` kernel test robot
2024-10-20  7:04 ` kernel test robot
2024-10-21  7:17 ` Dan Carpenter
2024-10-22  1:54   ` Guixin Liu [this message]
2024-10-22 15:44 ` Bjorn Helgaas
2024-10-24  3:42   ` Guixin Liu

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=56519e26-029d-46a1-b7cf-9391775da5bc@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=bhelgaas@google.com \
    --cc=dan.carpenter@linaro.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox