Message ID | 20200828063403.3995421-3-yangyingliang@huawei.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Delegated to: | Bjorn Helgaas |
Headers | show |
Series | fix memleak when using pci_iounmap() | expand |
Hi Yang,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on linux/master linus/master v5.9-rc2 next-20200828]
[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/Yang-Yingliang/fix-memleak-when-using-pci_iounmap/20200828-143645
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: microblaze-nommu_defconfig (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
microblaze-linux-ld: lib/pci_iomap.o: in function `pci_iounmap':
>> (.text+0x108): multiple definition of `pci_iounmap'; arch/microblaze/pci/iomap.o:(.text+0x0): first defined here
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Yang, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on pci/next] [also build test WARNING on linux/master linus/master v5.9-rc2 next-20200828] [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/Yang-Yingliang/fix-memleak-when-using-pci_iounmap/20200828-143645 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: powerpc64-randconfig-s032-20200828 (attached as .config) compiler: powerpc-linux-gcc (GCC) 9.3.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # apt-get install sparse # sparse version: v0.6.2-191-g10164920-dirty # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=powerpc64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> sparse warnings: (new ones prefixed by >>) >> drivers/scsi/mvumi.c:81:52: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem *addr @@ got void * @@ >> drivers/scsi/mvumi.c:81:52: sparse: expected void [noderef] __iomem *addr drivers/scsi/mvumi.c:81:52: sparse: got void * drivers/scsi/mvumi.c:90:39: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void * @@ got void [noderef] __iomem * @@ drivers/scsi/mvumi.c:90:39: sparse: expected void * drivers/scsi/mvumi.c:90:39: sparse: got void [noderef] __iomem * drivers/scsi/mvumi.c:210:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] baseaddr_l @@ got restricted __le32 [usertype] @@ drivers/scsi/mvumi.c:210:34: sparse: expected unsigned int [usertype] baseaddr_l drivers/scsi/mvumi.c:210:34: sparse: got restricted __le32 [usertype] drivers/scsi/mvumi.c:211:34: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] baseaddr_h @@ got restricted __le32 [usertype] @@ drivers/scsi/mvumi.c:211:34: sparse: expected unsigned int [usertype] baseaddr_h drivers/scsi/mvumi.c:211:34: sparse: got restricted __le32 [usertype] drivers/scsi/mvumi.c:213:17: sparse: sparse: invalid assignment: |= drivers/scsi/mvumi.c:213:17: sparse: left side has type unsigned int drivers/scsi/mvumi.c:213:17: sparse: right side has type restricted __le32 drivers/scsi/mvumi.c:213:17: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] size @@ got restricted __le32 [usertype] @@ drivers/scsi/mvumi.c:213:17: sparse: expected unsigned int [usertype] size drivers/scsi/mvumi.c:213:17: sparse: got restricted __le32 [usertype] drivers/scsi/mvumi.c:242:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] baseaddr_l @@ got restricted __le32 [usertype] @@ drivers/scsi/mvumi.c:242:26: sparse: expected unsigned int [usertype] baseaddr_l drivers/scsi/mvumi.c:242:26: sparse: got restricted __le32 [usertype] drivers/scsi/mvumi.c:243:26: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] baseaddr_h @@ got restricted __le32 [usertype] @@ drivers/scsi/mvumi.c:243:26: sparse: expected unsigned int [usertype] baseaddr_h drivers/scsi/mvumi.c:243:26: sparse: got restricted __le32 [usertype] drivers/scsi/mvumi.c:245:9: sparse: sparse: invalid assignment: |= drivers/scsi/mvumi.c:245:9: sparse: left side has type unsigned int drivers/scsi/mvumi.c:245:9: sparse: right side has type restricted __le32 drivers/scsi/mvumi.c:245:9: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int [usertype] size @@ got restricted __le32 [usertype] @@ drivers/scsi/mvumi.c:245:9: sparse: expected unsigned int [usertype] size drivers/scsi/mvumi.c:245:9: sparse: got restricted __le32 [usertype] drivers/scsi/mvumi.c:407:40: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *inb_read_pointer @@ drivers/scsi/mvumi.c:407:40: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:407:40: sparse: got void *inb_read_pointer drivers/scsi/mvumi.c:429:30: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *ib_shadow @@ drivers/scsi/mvumi.c:429:30: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:429:30: sparse: got void *ib_shadow drivers/scsi/mvumi.c:458:31: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *ib_shadow @@ drivers/scsi/mvumi.c:458:31: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:458:31: sparse: got void *ib_shadow drivers/scsi/mvumi.c:459:48: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *inb_write_pointer @@ drivers/scsi/mvumi.c:459:48: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:459:48: sparse: got void *inb_write_pointer drivers/scsi/mvumi.c:496:41: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *outb_copy_pointer @@ drivers/scsi/mvumi.c:496:41: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:496:41: sparse: got void *outb_copy_pointer drivers/scsi/mvumi.c:497:48: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *ob_shadow @@ drivers/scsi/mvumi.c:497:48: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:497:48: sparse: got void *ob_shadow drivers/scsi/mvumi.c:516:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *outb_read_pointer @@ drivers/scsi/mvumi.c:516:33: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:516:33: sparse: got void *outb_read_pointer drivers/scsi/mvumi.c:517:33: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *outb_copy_pointer @@ drivers/scsi/mvumi.c:517:33: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:517:33: sparse: got void *outb_copy_pointer drivers/scsi/mvumi.c:578:42: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *outb_read_pointer @@ drivers/scsi/mvumi.c:578:42: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:578:42: sparse: got void *outb_read_pointer drivers/scsi/mvumi.c:585:26: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *enpointa_mask_reg @@ drivers/scsi/mvumi.c:585:26: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:585:26: sparse: got void *enpointa_mask_reg drivers/scsi/mvumi.c:586:26: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *arm_to_pciea_msg1 @@ drivers/scsi/mvumi.c:586:26: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:586:26: sparse: got void *arm_to_pciea_msg1 drivers/scsi/mvumi.c:589:40: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *pciea_to_arm_drbl_reg @@ drivers/scsi/mvumi.c:589:40: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:589:40: sparse: got void *pciea_to_arm_drbl_reg drivers/scsi/mvumi.c:1281:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *arm_to_pciea_drbl_reg @@ drivers/scsi/mvumi.c:1281:28: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:1281:28: sparse: got void *arm_to_pciea_drbl_reg drivers/scsi/mvumi.c:1282:28: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *arm_to_pciea_drbl_reg @@ drivers/scsi/mvumi.c:1282:28: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:1282:28: sparse: got void *arm_to_pciea_drbl_reg drivers/scsi/mvumi.c:1284:48: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *arm_to_pciea_mask_reg @@ drivers/scsi/mvumi.c:1284:48: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:1284:48: sparse: got void *arm_to_pciea_mask_reg drivers/scsi/mvumi.c:1285:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *enpointa_mask_reg @@ drivers/scsi/mvumi.c:1285:28: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:1285:28: sparse: got void *enpointa_mask_reg drivers/scsi/mvumi.c:1286:28: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *enpointa_mask_reg @@ drivers/scsi/mvumi.c:1286:28: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:1286:28: sparse: got void *enpointa_mask_reg drivers/scsi/mvumi.c:612:26: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *enpointa_mask_reg @@ drivers/scsi/mvumi.c:612:26: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:612:26: sparse: got void *enpointa_mask_reg drivers/scsi/mvumi.c:613:28: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *arm_to_pciea_msg1 @@ drivers/scsi/mvumi.c:613:28: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:613:28: sparse: got void *arm_to_pciea_msg1 drivers/scsi/mvumi.c:615:46: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *pciea_to_arm_drbl_reg @@ drivers/scsi/mvumi.c:615:46: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:615:46: sparse: got void *pciea_to_arm_drbl_reg drivers/scsi/mvumi.c:624:36: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void const [noderef] __iomem * @@ got void *arm_to_pciea_msg1 @@ drivers/scsi/mvumi.c:624:36: sparse: expected void const [noderef] __iomem * drivers/scsi/mvumi.c:624:36: sparse: got void *arm_to_pciea_msg1 drivers/scsi/mvumi.c:670:32: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *reset_enable @@ drivers/scsi/mvumi.c:670:32: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:670:32: sparse: got void *reset_enable drivers/scsi/mvumi.c:671:34: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *reset_request @@ drivers/scsi/mvumi.c:671:34: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:671:34: sparse: got void *reset_request drivers/scsi/mvumi.c:673:35: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void [noderef] __iomem * @@ got void *reset_enable @@ drivers/scsi/mvumi.c:673:35: sparse: expected void [noderef] __iomem * drivers/scsi/mvumi.c:673:35: sparse: got void *reset_enable # https://github.com/0day-ci/linux/commit/6a62687154945b449554222ffe875acae4cd1cdb git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Yang-Yingliang/fix-memleak-when-using-pci_iounmap/20200828-143645 git checkout 6a62687154945b449554222ffe875acae4cd1cdb vim +81 drivers/scsi/mvumi.c f0c568a478f035 Jianyun Li 2011-05-11 73 f0c568a478f035 Jianyun Li 2011-05-11 74 static void mvumi_unmap_pci_addr(struct pci_dev *dev, void **addr_array) f0c568a478f035 Jianyun Li 2011-05-11 75 { f0c568a478f035 Jianyun Li 2011-05-11 76 int i; f0c568a478f035 Jianyun Li 2011-05-11 77 f0c568a478f035 Jianyun Li 2011-05-11 78 for (i = 0; i < MAX_BASE_ADDRESS; i++) f0c568a478f035 Jianyun Li 2011-05-11 79 if ((pci_resource_flags(dev, i) & IORESOURCE_MEM) && f0c568a478f035 Jianyun Li 2011-05-11 80 addr_array[i]) f0c568a478f035 Jianyun Li 2011-05-11 @81 pci_iounmap(dev, addr_array[i]); f0c568a478f035 Jianyun Li 2011-05-11 82 } f0c568a478f035 Jianyun Li 2011-05-11 83 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Hi Yang,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on linux/master linus/master v5.9-rc2 next-20200828]
[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/Yang-Yingliang/fix-memleak-when-using-pci_iounmap/20200828-143645
base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next
config: parisc-randconfig-s031-20200828 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-191-g10164920-dirty
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=parisc
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
hppa-linux-ld: arch/parisc/lib/iomap.o: in function `pci_iounmap':
>> arch/parisc/lib/iomap.c:498: multiple definition of `pci_iounmap'; lib/pci_iomap.o:lib/pci_iomap.c:141: first defined here
# https://github.com/0day-ci/linux/commit/6a62687154945b449554222ffe875acae4cd1cdb
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Yang-Yingliang/fix-memleak-when-using-pci_iounmap/20200828-143645
git checkout 6a62687154945b449554222ffe875acae4cd1cdb
vim +498 arch/parisc/lib/iomap.c
^1da177e4c3f415 Linus Torvalds 2005-04-16 492
^1da177e4c3f415 Linus Torvalds 2005-04-16 493 void ioport_unmap(void __iomem *addr)
^1da177e4c3f415 Linus Torvalds 2005-04-16 494 {
^1da177e4c3f415 Linus Torvalds 2005-04-16 495 if (!INDIRECT_ADDR(addr)) {
^1da177e4c3f415 Linus Torvalds 2005-04-16 496 iounmap(addr);
^1da177e4c3f415 Linus Torvalds 2005-04-16 497 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 @498 }
^1da177e4c3f415 Linus Torvalds 2005-04-16 499
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff --git a/include/asm-generic/pci_iomap.h b/include/asm-generic/pci_iomap.h index d4f16dcc2ed79..d6a04d2462238 100644 --- a/include/asm-generic/pci_iomap.h +++ b/include/asm-generic/pci_iomap.h @@ -18,6 +18,8 @@ extern void __iomem *pci_iomap_range(struct pci_dev *dev, int bar, extern void __iomem *pci_iomap_wc_range(struct pci_dev *dev, int bar, unsigned long offset, unsigned long maxlen); +#define pci_iounmap pci_iounmap +extern void pci_iounmap(struct pci_dev *dev, void __iomem * addr); /* Create a virtual mapping cookie for a port on a given PCI device. * Do not call this directly, it exists to make it easier for architectures * to override */ diff --git a/lib/iomap.c b/lib/iomap.c index d40bc6f662540..df0b3c5fa2065 100644 --- a/lib/iomap.c +++ b/lib/iomap.c @@ -337,13 +337,3 @@ void ioport_unmap(void __iomem *addr) EXPORT_SYMBOL(ioport_map); EXPORT_SYMBOL(ioport_unmap); #endif /* CONFIG_HAS_IOPORT_MAP */ - -#ifdef CONFIG_PCI -/* Hide the details if this is a MMIO or PIO address space and just do what - * you expect in the correct way. */ -void pci_iounmap(struct pci_dev *dev, void __iomem * addr) -{ - IO_COND(addr, /* nothing */, iounmap(addr)); -} -EXPORT_SYMBOL(pci_iounmap); -#endif /* CONFIG_PCI */ diff --git a/lib/pci_iomap.c b/lib/pci_iomap.c index 2d3eb1cb73b8f..833b702771ecd 100644 --- a/lib/pci_iomap.c +++ b/lib/pci_iomap.c @@ -134,4 +134,12 @@ void __iomem *pci_iomap_wc(struct pci_dev *dev, int bar, unsigned long maxlen) return pci_iomap_wc_range(dev, bar, 0, maxlen); } EXPORT_SYMBOL_GPL(pci_iomap_wc); + +/* Hide the details if this is a MMIO or PIO address space and just do what + * you expect in the correct way. */ +void pci_iounmap(struct pci_dev *dev, void __iomem * addr) +{ + IO_COND(addr, /* nothing */, iounmap(addr)); +} +EXPORT_SYMBOL(pci_iounmap); #endif /* CONFIG_PCI */
config GENERIC_IOMAP is disabled on some archs(e.g. arm64), so pci_iounmap() does nothing, when we using pci_iomap/pci_iounmap(), it will lead to memory leak. Move pci_iounmap() to lib/pci_map.c to fix this. Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- include/asm-generic/pci_iomap.h | 2 ++ lib/iomap.c | 10 ---------- lib/pci_iomap.c | 8 ++++++++ 3 files changed, 10 insertions(+), 10 deletions(-)