All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [riscv:next-misc 3/5] drivers/pci/pci-sysfs.c:1098:4: warning: performing pointer arithmetic on a null pointer has undefined behavior
@ 2021-05-24  5:37 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2021-05-24  5:37 UTC (permalink / raw
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 16807 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git next-misc
head:   a9672966c48014a7b3e03896b919e9e67b7de414
commit: b40f6bcb0448d69e0c842375fccdb91d60d61ab9 [3/5] riscv: enable generic PCI resource mapping
config: riscv-randconfig-r022-20210524 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 93d1e5822ed64abd777eb94ea9899e96c4c39fbe)
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
        # install riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git/commit/?id=b40f6bcb0448d69e0c842375fccdb91d60d61ab9
        git remote add riscv https://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux.git
        git fetch --no-tags riscv next-misc
        git checkout b40f6bcb0448d69e0c842375fccdb91d60d61ab9
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   In file included from drivers/pci/pci-sysfs.c:18:
   In file included from include/linux/pci.h:38:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:572:9: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           return inl(addr);
                  ^~~~~~~~~
   arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
   #define inl(c)          ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
                                                                           ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
   #define readl_cpu(c)            ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
                                                                                        ^
   include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   In file included from drivers/pci/pci-sysfs.c:18:
   In file included from include/linux/pci.h:38:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:580:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outb(value, addr);
           ^~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
   #define outb(v,c)       ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
   #define writeb_cpu(v, c)        ((void)__raw_writeb((v), (c)))
                                                             ^
   In file included from drivers/pci/pci-sysfs.c:18:
   In file included from include/linux/pci.h:38:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:588:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outw(value, addr);
           ^~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
   #define outw(v,c)       ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
   #define writew_cpu(v, c)        ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
                                                                                     ^
   In file included from drivers/pci/pci-sysfs.c:18:
   In file included from include/linux/pci.h:38:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:596:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outl(value, addr);
           ^~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
   #define outl(v,c)       ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
   #define writel_cpu(v, c)        ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
                                                                                     ^
   In file included from drivers/pci/pci-sysfs.c:18:
   In file included from include/linux/pci.h:38:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:11:
   In file included from ./arch/riscv/include/generated/asm/hardirq.h:1:
   In file included from include/asm-generic/hardirq.h:17:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/riscv/include/asm/io.h:149:
   include/asm-generic/io.h:1024:55: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           return (port > MMIO_UPPER_LIMIT) ? NULL : PCI_IOBASE + port;
                                                     ~~~~~~~~~~ ^
   In file included from drivers/pci/pci-sysfs.c:27:
   In file included from include/linux/vgaarb.h:34:
   include/video/vga.h:215:2: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
           outw(VGA_OUT16VAL (val, reg), port);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
   #define outw(v,c)       ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
   #define writew_cpu(v, c)        ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
                                                                                     ^
>> drivers/pci/pci-sysfs.c:1098:4: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                           outb(*(u8 *)buf, port);
                           ^~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:59:68: note: expanded from macro 'outb'
   #define outb(v,c)       ({ __io_pbw(); writeb_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:91:52: note: expanded from macro 'writeb_cpu'
   #define writeb_cpu(v, c)        ((void)__raw_writeb((v), (c)))
                                                             ^
   drivers/pci/pci-sysfs.c:1100:17: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                           *(u8 *)buf = inb(port);
                                        ^~~~~~~~~
   arch/riscv/include/asm/io.h:55:76: note: expanded from macro 'inb'
   #define inb(c)          ({ u8  __v; __io_pbr(); __v = readb_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
                                                                           ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:87:48: note: expanded from macro 'readb_cpu'
   #define readb_cpu(c)            ({ u8  __r = __raw_readb(c); __r; })
                                                            ^
   drivers/pci/pci-sysfs.c:1104:4: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                           outw(*(u16 *)buf, port);
                           ^~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:60:68: note: expanded from macro 'outw'
   #define outw(v,c)       ({ __io_pbw(); writew_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:92:76: note: expanded from macro 'writew_cpu'
   #define writew_cpu(v, c)        ((void)__raw_writew((__force u16)cpu_to_le16(v), (c)))
                                                                                     ^
   drivers/pci/pci-sysfs.c:1106:18: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                           *(u16 *)buf = inw(port);
                                         ^~~~~~~~~
   arch/riscv/include/asm/io.h:56:76: note: expanded from macro 'inw'
   #define inw(c)          ({ u16 __v; __io_pbr(); __v = readw_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
                                                                           ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:88:76: note: expanded from macro 'readw_cpu'
   #define readw_cpu(c)            ({ u16 __r = le16_to_cpu((__force __le16)__raw_readw(c)); __r; })
                                                                                        ^
   include/uapi/linux/byteorder/little_endian.h:36:51: note: expanded from macro '__le16_to_cpu'
   #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                                     ^
   drivers/pci/pci-sysfs.c:1110:4: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                           outl(*(u32 *)buf, port);
                           ^~~~~~~~~~~~~~~~~~~~~~~
   arch/riscv/include/asm/io.h:61:68: note: expanded from macro 'outl'
   #define outl(v,c)       ({ __io_pbw(); writel_cpu((v),(void*)(PCI_IOBASE + (c))); __io_paw(); })
                                                                 ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:93:76: note: expanded from macro 'writel_cpu'
   #define writel_cpu(v, c)        ((void)__raw_writel((__force u32)cpu_to_le32(v), (c)))
                                                                                     ^
   drivers/pci/pci-sysfs.c:1112:18: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
                           *(u32 *)buf = inl(port);
                                         ^~~~~~~~~
   arch/riscv/include/asm/io.h:57:76: note: expanded from macro 'inl'
   #define inl(c)          ({ u32 __v; __io_pbr(); __v = readl_cpu((void*)(PCI_IOBASE + (c))); __io_par(__v); __v; })
                                                                           ~~~~~~~~~~ ^
   arch/riscv/include/asm/mmio.h:89:76: note: expanded from macro 'readl_cpu'
   #define readl_cpu(c)            ({ u32 __r = le32_to_cpu((__force __le32)__raw_readl(c)); __r; })
                                                                                        ^
   include/uapi/linux/byteorder/little_endian.h:34:51: note: expanded from macro '__le32_to_cpu'
   #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
                                                     ^
   14 warnings generated.

Kconfig warnings: (for reference only)
   WARNING: unmet direct dependencies detected for LOCKDEP
   Depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT && (FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86)
   Selected by
   - PROVE_LOCKING && DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
   - DEBUG_LOCK_ALLOC && DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT


vim +1098 drivers/pci/pci-sysfs.c

^1da177e4c3f41 Linus Torvalds  2005-04-16  1078  
3c78bc61f5ef3b Ryan Desfosses  2014-04-18  1079  static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
8633328be24267 Alex Williamson 2010-07-19  1080  			       struct bin_attribute *attr, char *buf,
8633328be24267 Alex Williamson 2010-07-19  1081  			       loff_t off, size_t count, bool write)
8633328be24267 Alex Williamson 2010-07-19  1082  {
554a60379aaa50 Geliang Tang    2015-12-23  1083  	struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
dca40b186b757c David Woodhouse 2017-04-12  1084  	int bar = (unsigned long)attr->private;
8633328be24267 Alex Williamson 2010-07-19  1085  	unsigned long port = off;
8633328be24267 Alex Williamson 2010-07-19  1086  
dca40b186b757c David Woodhouse 2017-04-12  1087  	port += pci_resource_start(pdev, bar);
8633328be24267 Alex Williamson 2010-07-19  1088  
dca40b186b757c David Woodhouse 2017-04-12  1089  	if (port > pci_resource_end(pdev, bar))
8633328be24267 Alex Williamson 2010-07-19  1090  		return 0;
8633328be24267 Alex Williamson 2010-07-19  1091  
dca40b186b757c David Woodhouse 2017-04-12  1092  	if (port + count - 1 > pci_resource_end(pdev, bar))
8633328be24267 Alex Williamson 2010-07-19  1093  		return -EINVAL;
8633328be24267 Alex Williamson 2010-07-19  1094  
8633328be24267 Alex Williamson 2010-07-19  1095  	switch (count) {
8633328be24267 Alex Williamson 2010-07-19  1096  	case 1:
8633328be24267 Alex Williamson 2010-07-19  1097  		if (write)
8633328be24267 Alex Williamson 2010-07-19 @1098  			outb(*(u8 *)buf, port);
8633328be24267 Alex Williamson 2010-07-19  1099  		else
8633328be24267 Alex Williamson 2010-07-19  1100  			*(u8 *)buf = inb(port);
8633328be24267 Alex Williamson 2010-07-19  1101  		return 1;
8633328be24267 Alex Williamson 2010-07-19  1102  	case 2:
8633328be24267 Alex Williamson 2010-07-19  1103  		if (write)
8633328be24267 Alex Williamson 2010-07-19  1104  			outw(*(u16 *)buf, port);
8633328be24267 Alex Williamson 2010-07-19  1105  		else
8633328be24267 Alex Williamson 2010-07-19  1106  			*(u16 *)buf = inw(port);
8633328be24267 Alex Williamson 2010-07-19  1107  		return 2;
8633328be24267 Alex Williamson 2010-07-19  1108  	case 4:
8633328be24267 Alex Williamson 2010-07-19  1109  		if (write)
8633328be24267 Alex Williamson 2010-07-19  1110  			outl(*(u32 *)buf, port);
8633328be24267 Alex Williamson 2010-07-19  1111  		else
8633328be24267 Alex Williamson 2010-07-19  1112  			*(u32 *)buf = inl(port);
8633328be24267 Alex Williamson 2010-07-19  1113  		return 4;
8633328be24267 Alex Williamson 2010-07-19  1114  	}
8633328be24267 Alex Williamson 2010-07-19  1115  	return -EINVAL;
8633328be24267 Alex Williamson 2010-07-19  1116  }
8633328be24267 Alex Williamson 2010-07-19  1117  

:::::: The code at line 1098 was first introduced by commit
:::::: 8633328be242677fdedc42052838dd0608e7f342 PCI: Allow read/write access to sysfs I/O port resources

:::::: TO: Alex Williamson <alex.williamson@redhat.com>
:::::: CC: Jesse Barnes <jbarnes@virtuousgeek.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 21365 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-24  5:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-24  5:37 [riscv:next-misc 3/5] drivers/pci/pci-sysfs.c:1098:4: warning: performing pointer arithmetic on a null pointer has undefined behavior kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.