* [PATCH 1/2] iomap: move some definitions to include/linux/io.h
2020-08-28 6:34 [PATCH 0/2] fix memleak when using pci_iounmap() Yang Yingliang
@ 2020-08-28 6:34 ` Yang Yingliang
2020-08-28 6:34 ` [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap() Yang Yingliang
2020-08-28 16:06 ` [PATCH 0/2] fix memleak when using pci_iounmap() Bjorn Helgaas
2 siblings, 0 replies; 7+ messages in thread
From: Yang Yingliang @ 2020-08-28 6:34 UTC (permalink / raw)
To: linux-kernel, linux-pci; +Cc: bhelgaas, guohanjun, yangyingliang
Move some IO macros and bad_io_access() to include/linux/io.h
This prepares for moving pci_iounmap() to lib/pci_iomap.c.
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
include/linux/io.h | 36 ++++++++++++++++++++++++++++++++++++
lib/iomap.c | 36 ------------------------------------
2 files changed, 36 insertions(+), 36 deletions(-)
diff --git a/include/linux/io.h b/include/linux/io.h
index 8394c56babc26..fa040f8114eaa 100644
--- a/include/linux/io.h
+++ b/include/linux/io.h
@@ -13,6 +13,42 @@
#include <asm/io.h>
#include <asm/page.h>
+#ifndef HAVE_ARCH_PIO_SIZE
+/*
+ * We encode the physical PIO addresses (0-0xffff) into the
+ * pointer by offsetting them with a constant (0x10000) and
+ * assuming that all the low addresses are always PIO. That means
+ * we can do some sanity checks on the low bits, and don't
+ * need to just take things for granted.
+ */
+#define PIO_OFFSET 0x10000UL
+#define PIO_MASK 0x0ffffUL
+#define PIO_RESERVED 0x40000UL
+#endif
+
+static inline void bad_io_access(unsigned long port, const char *access)
+{
+ static int count = 10;
+ if (count) {
+ count--;
+ WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
+ }
+}
+
+/*
+ * Ugly macros are a way of life.
+ */
+#define IO_COND(addr, is_pio, is_mmio) do { \
+ unsigned long port = (unsigned long __force)addr; \
+ if (port >= PIO_RESERVED) { \
+ is_mmio; \
+ } else if (port > PIO_OFFSET) { \
+ port &= PIO_MASK; \
+ is_pio; \
+ } else \
+ bad_io_access(port, #is_pio); \
+} while (0)
+
struct device;
struct resource;
diff --git a/lib/iomap.c b/lib/iomap.c
index fbaa3e8f19d6c..d40bc6f662540 100644
--- a/lib/iomap.c
+++ b/lib/iomap.c
@@ -23,42 +23,6 @@
* implementation and should do their own copy.
*/
-#ifndef HAVE_ARCH_PIO_SIZE
-/*
- * We encode the physical PIO addresses (0-0xffff) into the
- * pointer by offsetting them with a constant (0x10000) and
- * assuming that all the low addresses are always PIO. That means
- * we can do some sanity checks on the low bits, and don't
- * need to just take things for granted.
- */
-#define PIO_OFFSET 0x10000UL
-#define PIO_MASK 0x0ffffUL
-#define PIO_RESERVED 0x40000UL
-#endif
-
-static void bad_io_access(unsigned long port, const char *access)
-{
- static int count = 10;
- if (count) {
- count--;
- WARN(1, KERN_ERR "Bad IO access at port %#lx (%s)\n", port, access);
- }
-}
-
-/*
- * Ugly macros are a way of life.
- */
-#define IO_COND(addr, is_pio, is_mmio) do { \
- unsigned long port = (unsigned long __force)addr; \
- if (port >= PIO_RESERVED) { \
- is_mmio; \
- } else if (port > PIO_OFFSET) { \
- port &= PIO_MASK; \
- is_pio; \
- } else \
- bad_io_access(port, #is_pio ); \
-} while (0)
-
#ifndef pio_read16be
#define pio_read16be(port) swab16(inw(port))
#define pio_read32be(port) swab32(inl(port))
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap()
2020-08-28 6:34 [PATCH 0/2] fix memleak when using pci_iounmap() Yang Yingliang
2020-08-28 6:34 ` [PATCH 1/2] iomap: move some definitions to include/linux/io.h Yang Yingliang
@ 2020-08-28 6:34 ` Yang Yingliang
2020-08-28 10:19 ` kernel test robot
` (2 more replies)
2020-08-28 16:06 ` [PATCH 0/2] fix memleak when using pci_iounmap() Bjorn Helgaas
2 siblings, 3 replies; 7+ messages in thread
From: Yang Yingliang @ 2020-08-28 6:34 UTC (permalink / raw)
To: linux-kernel, linux-pci; +Cc: bhelgaas, guohanjun, yangyingliang
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(-)
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 */
--
2.25.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap()
2020-08-28 6:34 ` [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap() Yang Yingliang
@ 2020-08-28 10:19 ` kernel test robot
2020-08-28 11:24 ` kernel test robot
2020-08-28 13:35 ` kernel test robot
2 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-08-28 10:19 UTC (permalink / raw)
To: Yang Yingliang, linux-kernel, linux-pci
Cc: kbuild-all, bhelgaas, guohanjun, yangyingliang
[-- Attachment #1: Type: text/plain, Size: 1418 bytes --]
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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 14265 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap()
2020-08-28 6:34 ` [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap() Yang Yingliang
2020-08-28 10:19 ` kernel test robot
@ 2020-08-28 11:24 ` kernel test robot
2020-08-28 13:35 ` kernel test robot
2 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-08-28 11:24 UTC (permalink / raw)
To: Yang Yingliang, linux-kernel, linux-pci
Cc: kbuild-all, bhelgaas, guohanjun, yangyingliang
[-- Attachment #1: Type: text/plain, Size: 13675 bytes --]
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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 32760 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap()
2020-08-28 6:34 ` [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap() Yang Yingliang
2020-08-28 10:19 ` kernel test robot
2020-08-28 11:24 ` kernel test robot
@ 2020-08-28 13:35 ` kernel test robot
2 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2020-08-28 13:35 UTC (permalink / raw)
To: Yang Yingliang, linux-kernel, linux-pci
Cc: kbuild-all, bhelgaas, guohanjun, yangyingliang
[-- Attachment #1: Type: text/plain, Size: 2346 bytes --]
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
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28162 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] fix memleak when using pci_iounmap()
2020-08-28 6:34 [PATCH 0/2] fix memleak when using pci_iounmap() Yang Yingliang
2020-08-28 6:34 ` [PATCH 1/2] iomap: move some definitions to include/linux/io.h Yang Yingliang
2020-08-28 6:34 ` [PATCH 2/2] pci: fix memleak when calling pci_iomap/unmap() Yang Yingliang
@ 2020-08-28 16:06 ` Bjorn Helgaas
2 siblings, 0 replies; 7+ messages in thread
From: Bjorn Helgaas @ 2020-08-28 16:06 UTC (permalink / raw)
To: Yang Yingliang
Cc: linux-kernel, linux-pci, bhelgaas, guohanjun, George Cherian
[+cc George]
On Fri, Aug 28, 2020 at 02:34:01PM +0800, Yang Yingliang wrote:
> config GENERIC_IOMAP is not selected on some arch, pci_iounmap()
> don't implement, when we using pci_iomap/pci_iounmap, it will
> lead to memory leak.
> This patch set moves the implemention of pci_iounmap() to
> lib/pci_iomap.c to fix this.
>
> Yang Yingliang (2):
> iomap: move some definitions to include/linux/io.h
> pci: fix memleak when calling pci_iomap/unmap()
>
> include/asm-generic/pci_iomap.h | 2 ++
> include/linux/io.h | 36 ++++++++++++++++++++++++++
> lib/iomap.c | 46 ---------------------------------
> lib/pci_iomap.c | 8 ++++++
> 4 files changed, 46 insertions(+), 46 deletions(-)
I haven't looked at this yet (and won't because of the build issues),
but please note George's previous similar work:
https://lore.kernel.org/linux-pci/20200824132046.3114383-1-george.cherian@marvell.com/
I haven't compared them, so just FYI that we'll have to integrate them
somehow.
If/when you repost this, please run "git log --oneline" and match the
subject styles. And add blank lines between paragraphs. Use "()"
consistently after function names. And please cc: George, of course.
Bjorn
^ permalink raw reply [flat|nested] 7+ messages in thread