* Re: [PATCH v5 02/10] PCI: Deprecate iomap-table functions
@ 2024-04-04 1:38 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2024-04-04 1:38 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240403080712.13986-5-pstanner@redhat.com>
References: <20240403080712.13986-5-pstanner@redhat.com>
TO: Philipp Stanner <pstanner@redhat.com>
TO: Hans de Goede <hdegoede@redhat.com>
TO: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
TO: Maxime Ripard <mripard@kernel.org>
TO: Thomas Zimmermann <tzimmermann@suse.de>
TO: David Airlie <airlied@gmail.com>
TO: Daniel Vetter <daniel@ffwll.ch>
TO: Bjorn Helgaas <helgaas@kernel.org>
TO: Sam Ravnborg <sam@ravnborg.org>
TO: dakr@redhat.com
CC: dri-devel@lists.freedesktop.org
CC: linux-kernel@vger.kernel.org
CC: linux-pci@vger.kernel.org
CC: Philipp Stanner <pstanner@redhat.com>
Hi Philipp,
kernel test robot noticed the following build warnings:
[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus drm-misc/drm-misc-next linus/master v6.9-rc2 next-20240403]
[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#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Philipp-Stanner/PCI-Add-new-set-of-devres-functions/20240403-160932
base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link: https://lore.kernel.org/r/20240403080712.13986-5-pstanner%40redhat.com
patch subject: [PATCH v5 02/10] PCI: Deprecate iomap-table functions
:::::: branch date: 17 hours ago
:::::: commit date: 17 hours ago
config: i386-randconfig-141-20240404 (https://download.01.org/0day-ci/archive/20240404/202404040920.QIxhNeMu-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.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 <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202404040920.QIxhNeMu-lkp@intel.com/
smatch warnings:
drivers/pci/devres.c:897 pcim_iomap_regions_request_all() error: we previously assumed 'legacy_iomap_table' could be null (see line 894)
vim +/legacy_iomap_table +897 drivers/pci/devres.c
acc2364fe66106 Philipp Stanner 2024-01-31 848
acc2364fe66106 Philipp Stanner 2024-01-31 849 /**
34e90b966504f3 Philipp Stanner 2024-04-03 850 * pcim_iomap_regions_request_all - Request all BARs and iomap specified ones (DEPRECATED)
acc2364fe66106 Philipp Stanner 2024-01-31 851 * @pdev: PCI device to map IO resources for
acc2364fe66106 Philipp Stanner 2024-01-31 852 * @mask: Mask of BARs to iomap
4a97db2d40b2a0 Philipp Stanner 2024-04-03 853 * @name: Name associated with the requests
acc2364fe66106 Philipp Stanner 2024-01-31 854 *
34e90b966504f3 Philipp Stanner 2024-04-03 855 * Returns: 0 on success, negative error code on failure.
34e90b966504f3 Philipp Stanner 2024-04-03 856 *
acc2364fe66106 Philipp Stanner 2024-01-31 857 * Request all PCI BARs and iomap regions specified by @mask.
34e90b966504f3 Philipp Stanner 2024-04-03 858 *
34e90b966504f3 Philipp Stanner 2024-04-03 859 * To release these resources manually, call pcim_release_region() for the
34e90b966504f3 Philipp Stanner 2024-04-03 860 * regions and pcim_iounmap() for the mappings.
34e90b966504f3 Philipp Stanner 2024-04-03 861 *
34e90b966504f3 Philipp Stanner 2024-04-03 862 * This function is DEPRECATED. Don't use it in new code.
34e90b966504f3 Philipp Stanner 2024-04-03 863 * Use pcim_request_all_regions() + pcim_iomap*() instead.
acc2364fe66106 Philipp Stanner 2024-01-31 864 */
acc2364fe66106 Philipp Stanner 2024-01-31 865 int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
acc2364fe66106 Philipp Stanner 2024-01-31 866 const char *name)
acc2364fe66106 Philipp Stanner 2024-01-31 867 {
34e90b966504f3 Philipp Stanner 2024-04-03 868 short bar;
34e90b966504f3 Philipp Stanner 2024-04-03 869 int ret;
34e90b966504f3 Philipp Stanner 2024-04-03 870 void __iomem **legacy_iomap_table;
acc2364fe66106 Philipp Stanner 2024-01-31 871
34e90b966504f3 Philipp Stanner 2024-04-03 872 ret = pcim_request_all_regions(pdev, name);
34e90b966504f3 Philipp Stanner 2024-04-03 873 if (ret != 0)
34e90b966504f3 Philipp Stanner 2024-04-03 874 return ret;
acc2364fe66106 Philipp Stanner 2024-01-31 875
34e90b966504f3 Philipp Stanner 2024-04-03 876 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
34e90b966504f3 Philipp Stanner 2024-04-03 877 if (!mask_contains_bar(mask, bar))
34e90b966504f3 Philipp Stanner 2024-04-03 878 continue;
34e90b966504f3 Philipp Stanner 2024-04-03 879 if (!pcim_iomap(pdev, bar, 0))
34e90b966504f3 Philipp Stanner 2024-04-03 880 goto err;
34e90b966504f3 Philipp Stanner 2024-04-03 881 }
34e90b966504f3 Philipp Stanner 2024-04-03 882
34e90b966504f3 Philipp Stanner 2024-04-03 883 return 0;
34e90b966504f3 Philipp Stanner 2024-04-03 884
34e90b966504f3 Philipp Stanner 2024-04-03 885 err:
34e90b966504f3 Philipp Stanner 2024-04-03 886 /*
34e90b966504f3 Philipp Stanner 2024-04-03 887 * Here it gets tricky: pcim_iomap() above has most likely
34e90b966504f3 Philipp Stanner 2024-04-03 888 * failed because it got an OOM when trying to create the
34e90b966504f3 Philipp Stanner 2024-04-03 889 * legacy-table.
34e90b966504f3 Philipp Stanner 2024-04-03 890 * We check here if that has happened. If not, pcim_iomap()
34e90b966504f3 Philipp Stanner 2024-04-03 891 * must have failed because of EINVAL.
34e90b966504f3 Philipp Stanner 2024-04-03 892 */
34e90b966504f3 Philipp Stanner 2024-04-03 893 legacy_iomap_table = (void __iomem **)pcim_iomap_table(pdev);
34e90b966504f3 Philipp Stanner 2024-04-03 @894 ret = legacy_iomap_table ? -EINVAL : -ENOMEM;
34e90b966504f3 Philipp Stanner 2024-04-03 895
34e90b966504f3 Philipp Stanner 2024-04-03 896 while (--bar >= 0)
34e90b966504f3 Philipp Stanner 2024-04-03 @897 pcim_iounmap(pdev, legacy_iomap_table[bar]);
34e90b966504f3 Philipp Stanner 2024-04-03 898
34e90b966504f3 Philipp Stanner 2024-04-03 899 pcim_release_all_regions(pdev);
34e90b966504f3 Philipp Stanner 2024-04-03 900
34e90b966504f3 Philipp Stanner 2024-04-03 901 return ret;
acc2364fe66106 Philipp Stanner 2024-01-31 902 }
acc2364fe66106 Philipp Stanner 2024-01-31 903 EXPORT_SYMBOL(pcim_iomap_regions_request_all);
acc2364fe66106 Philipp Stanner 2024-01-31 904
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v5 02/10] PCI: Deprecate iomap-table functions
2024-04-04 6:29 ` Dan Carpenter
@ 2024-04-04 7:15 ` Philipp Stanner
0 siblings, 0 replies; 3+ messages in thread
From: Philipp Stanner @ 2024-04-04 7:15 UTC (permalink / raw)
To: Dan Carpenter, oe-kbuild, Hans de Goede, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter,
Bjorn Helgaas, Sam Ravnborg, dakr
Cc: lkp, oe-kbuild-all, dri-devel, linux-kernel, linux-pci
Hello,
On Thu, 2024-04-04 at 09:29 +0300, Dan Carpenter wrote:
> Hi Philipp,
>
> 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/Philipp-Stanner/PCI-Add-new-set-of-devres-functions/20240403-160932
> base:
> https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
> patch link:
> https://lore.kernel.org/r/20240403080712.13986-5-pstanner%40redhat.com
> patch subject: [PATCH v5 02/10] PCI: Deprecate iomap-table functions
> config: i386-randconfig-141-20240404
> (https://download.01.org/0day-ci/archive/20240404/202404040920.QIxhNe
> Mu-lkp@intel.com/config)
> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.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/202404040920.QIxhNeMu-lkp@intel.com/
>
> smatch warnings:
> drivers/pci/devres.c:897 pcim_iomap_regions_request_all() error: we
> previously assumed 'legacy_iomap_table' could be null (see line 894)
>
> vim +/legacy_iomap_table +897 drivers/pci/devres.c
>
> acc2364fe66106 Philipp Stanner 2024-01-31 865 int
> pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
> acc2364fe66106 Philipp Stanner 2024-01-31
> 866 const char *name)
> acc2364fe66106 Philipp Stanner 2024-01-31 867 {
> 34e90b966504f3 Philipp Stanner 2024-04-03 868 short bar;
> 34e90b966504f3 Philipp Stanner 2024-04-03 869 int ret;
> 34e90b966504f3 Philipp Stanner 2024-04-03 870 void __iomem
> **legacy_iomap_table;
> acc2364fe66106 Philipp Stanner 2024-01-31 871
> 34e90b966504f3 Philipp Stanner 2024-04-03 872 ret =
> pcim_request_all_regions(pdev, name);
> 34e90b966504f3 Philipp Stanner 2024-04-03 873 if (ret != 0)
> 34e90b966504f3 Philipp Stanner 2024-04-03
> 874 return ret;
> acc2364fe66106 Philipp Stanner 2024-01-31 875
> 34e90b966504f3 Philipp Stanner 2024-04-03 876 for (bar = 0;
> bar < PCI_STD_NUM_BARS; bar++) {
> 34e90b966504f3 Philipp Stanner 2024-04-03 877 if
> (!mask_contains_bar(mask, bar))
> 34e90b966504f3 Philipp Stanner 2024-04-03
> 878 continue;
> 34e90b966504f3 Philipp Stanner 2024-04-03 879 if
> (!pcim_iomap(pdev, bar, 0))
> 34e90b966504f3 Philipp Stanner 2024-04-03
> 880 goto err;
> 34e90b966504f3 Philipp Stanner 2024-04-03 881 }
> 34e90b966504f3 Philipp Stanner 2024-04-03 882
> 34e90b966504f3 Philipp Stanner 2024-04-03 883 return 0;
> 34e90b966504f3 Philipp Stanner 2024-04-03 884
> 34e90b966504f3 Philipp Stanner 2024-04-03 885 err:
> 34e90b966504f3 Philipp Stanner 2024-04-03 886 /*
> 34e90b966504f3 Philipp Stanner 2024-04-03 887 * Here it
> gets tricky: pcim_iomap() above has most likely
> 34e90b966504f3 Philipp Stanner 2024-04-03 888 * failed
> because it got an OOM when trying to create the
> 34e90b966504f3 Philipp Stanner 2024-04-03 889 * legacy-
> table.
> 34e90b966504f3 Philipp Stanner 2024-04-03 890 * We check
> here if that has happened. If not, pcim_iomap()
> 34e90b966504f3 Philipp Stanner 2024-04-03 891 * must have
> failed because of EINVAL.
> 34e90b966504f3 Philipp Stanner 2024-04-03 892 */
> 34e90b966504f3 Philipp Stanner 2024-04-03
> 893 legacy_iomap_table = (void __iomem
> **)pcim_iomap_table(pdev);
> 34e90b966504f3 Philipp Stanner 2024-04-03 @894 ret =
> legacy_iomap_table ? -EINVAL : -ENOMEM;
>
> ^^^^^^^^^^^^^^^^^^
> Check for NULL
>
> 34e90b966504f3 Philipp Stanner 2024-04-03 895
> 34e90b966504f3 Philipp Stanner 2024-04-03 896 while (--bar
> >= 0)
> 34e90b966504f3 Philipp Stanner 2024-04-03
> @897 pcim_iounmap(pdev, legacy_iomap_table[bar]);
>
> ^^^^^^^^^^^^^^^^^^
> Unchecked dereference
I think this is fine because `bar` can only be larger 0 if at least one
mapping has been created, thus, when it was possible to create
legacy_iomap_table, which is then valid.
So the second for-loop only executes when it's not NULL.
I guess we could silence the warning by doing
ret = bar > 0 ? -EINVAL : -ENOMEM;
Would even save one line of code
P.
>
> 34e90b966504f3 Philipp Stanner 2024-04-03 898
> 34e90b966504f3 Philipp Stanner 2024-04-03
> 899 pcim_release_all_regions(pdev);
> 34e90b966504f3 Philipp Stanner 2024-04-03 900
> 34e90b966504f3 Philipp Stanner 2024-04-03 901 return ret;
> acc2364fe66106 Philipp Stanner 2024-01-31 902 }
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v5 02/10] PCI: Deprecate iomap-table functions
[not found] <20240403080712.13986-5-pstanner@redhat.com>
@ 2024-04-04 6:29 ` Dan Carpenter
2024-04-04 7:15 ` Philipp Stanner
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-04-04 6:29 UTC (permalink / raw)
To: oe-kbuild, Philipp Stanner, Hans de Goede, Maarten Lankhorst,
Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter,
Bjorn Helgaas, Sam Ravnborg, dakr
Cc: lkp, oe-kbuild-all, dri-devel, linux-kernel, linux-pci, Philipp Stanner
Hi Philipp,
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/Philipp-Stanner/PCI-Add-new-set-of-devres-functions/20240403-160932
base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link: https://lore.kernel.org/r/20240403080712.13986-5-pstanner%40redhat.com
patch subject: [PATCH v5 02/10] PCI: Deprecate iomap-table functions
config: i386-randconfig-141-20240404 (https://download.01.org/0day-ci/archive/20240404/202404040920.QIxhNeMu-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.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/202404040920.QIxhNeMu-lkp@intel.com/
smatch warnings:
drivers/pci/devres.c:897 pcim_iomap_regions_request_all() error: we previously assumed 'legacy_iomap_table' could be null (see line 894)
vim +/legacy_iomap_table +897 drivers/pci/devres.c
acc2364fe66106 Philipp Stanner 2024-01-31 865 int pcim_iomap_regions_request_all(struct pci_dev *pdev, int mask,
acc2364fe66106 Philipp Stanner 2024-01-31 866 const char *name)
acc2364fe66106 Philipp Stanner 2024-01-31 867 {
34e90b966504f3 Philipp Stanner 2024-04-03 868 short bar;
34e90b966504f3 Philipp Stanner 2024-04-03 869 int ret;
34e90b966504f3 Philipp Stanner 2024-04-03 870 void __iomem **legacy_iomap_table;
acc2364fe66106 Philipp Stanner 2024-01-31 871
34e90b966504f3 Philipp Stanner 2024-04-03 872 ret = pcim_request_all_regions(pdev, name);
34e90b966504f3 Philipp Stanner 2024-04-03 873 if (ret != 0)
34e90b966504f3 Philipp Stanner 2024-04-03 874 return ret;
acc2364fe66106 Philipp Stanner 2024-01-31 875
34e90b966504f3 Philipp Stanner 2024-04-03 876 for (bar = 0; bar < PCI_STD_NUM_BARS; bar++) {
34e90b966504f3 Philipp Stanner 2024-04-03 877 if (!mask_contains_bar(mask, bar))
34e90b966504f3 Philipp Stanner 2024-04-03 878 continue;
34e90b966504f3 Philipp Stanner 2024-04-03 879 if (!pcim_iomap(pdev, bar, 0))
34e90b966504f3 Philipp Stanner 2024-04-03 880 goto err;
34e90b966504f3 Philipp Stanner 2024-04-03 881 }
34e90b966504f3 Philipp Stanner 2024-04-03 882
34e90b966504f3 Philipp Stanner 2024-04-03 883 return 0;
34e90b966504f3 Philipp Stanner 2024-04-03 884
34e90b966504f3 Philipp Stanner 2024-04-03 885 err:
34e90b966504f3 Philipp Stanner 2024-04-03 886 /*
34e90b966504f3 Philipp Stanner 2024-04-03 887 * Here it gets tricky: pcim_iomap() above has most likely
34e90b966504f3 Philipp Stanner 2024-04-03 888 * failed because it got an OOM when trying to create the
34e90b966504f3 Philipp Stanner 2024-04-03 889 * legacy-table.
34e90b966504f3 Philipp Stanner 2024-04-03 890 * We check here if that has happened. If not, pcim_iomap()
34e90b966504f3 Philipp Stanner 2024-04-03 891 * must have failed because of EINVAL.
34e90b966504f3 Philipp Stanner 2024-04-03 892 */
34e90b966504f3 Philipp Stanner 2024-04-03 893 legacy_iomap_table = (void __iomem **)pcim_iomap_table(pdev);
34e90b966504f3 Philipp Stanner 2024-04-03 @894 ret = legacy_iomap_table ? -EINVAL : -ENOMEM;
^^^^^^^^^^^^^^^^^^
Check for NULL
34e90b966504f3 Philipp Stanner 2024-04-03 895
34e90b966504f3 Philipp Stanner 2024-04-03 896 while (--bar >= 0)
34e90b966504f3 Philipp Stanner 2024-04-03 @897 pcim_iounmap(pdev, legacy_iomap_table[bar]);
^^^^^^^^^^^^^^^^^^
Unchecked dereference
34e90b966504f3 Philipp Stanner 2024-04-03 898
34e90b966504f3 Philipp Stanner 2024-04-03 899 pcim_release_all_regions(pdev);
34e90b966504f3 Philipp Stanner 2024-04-03 900
34e90b966504f3 Philipp Stanner 2024-04-03 901 return ret;
acc2364fe66106 Philipp Stanner 2024-01-31 902 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-04 7:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-04 1:38 [PATCH v5 02/10] PCI: Deprecate iomap-table functions kernel test robot
[not found] <20240403080712.13986-5-pstanner@redhat.com>
2024-04-04 6:29 ` Dan Carpenter
2024-04-04 7:15 ` Philipp Stanner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).