arch/s390/pci/pci_mmio.c:35:1: sparse: sparse: Using plain integer as NULL pointer

From: kernel test robot
Date: Sat Dec 09 2023 - 08:23:27 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f2e8a57ee9036c7d5443382b6c3c09b51a92ec7e
commit: aa0d6e70d3b34e710a6a57a53a3096cb2e0ea99f s390: autogenerate compat syscall wrappers
date: 4 years, 11 months ago
config: s390-randconfig-r113-20231115 (https://download.01.org/0day-ci/archive/20231209/202312092144.nRcv9gfg-lkp@xxxxxxxxx/config)
compiler: s390-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20231209/202312092144.nRcv9gfg-lkp@xxxxxxxxx/reproduce)

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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312092144.nRcv9gfg-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> arch/s390/pci/pci_mmio.c:35:1: sparse: sparse: Using plain integer as NULL pointer
>> arch/s390/pci/pci_mmio.c:35:1: sparse: sparse: Using plain integer as NULL pointer
arch/s390/pci/pci_mmio.c:75:1: sparse: sparse: Using plain integer as NULL pointer
arch/s390/pci/pci_mmio.c:75:1: sparse: sparse: Using plain integer as NULL pointer
--
>> kernel/acct.c:273:1: sparse: sparse: Using plain integer as NULL pointer
>> kernel/acct.c:273:1: sparse: sparse: Using plain integer as NULL pointer
kernel/acct.c:193:12: sparse: sparse: context imbalance in 'acct_on' - different lock contexts for basic block
kernel/acct.c:294:9: sparse: sparse: context imbalance in '__se_sys_acct' - different lock contexts for basic block
kernel/acct.c:297:6: sparse: sparse: context imbalance in 'acct_exit_ns' - wrong count at exit

vim +35 arch/s390/pci/pci_mmio.c

4eafad7febd482 Alexey Ishchuk 2014-11-14 34
4eafad7febd482 Alexey Ishchuk 2014-11-14 @35 SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
4eafad7febd482 Alexey Ishchuk 2014-11-14 36 const void __user *, user_buffer, size_t, length)
4eafad7febd482 Alexey Ishchuk 2014-11-14 37 {
4eafad7febd482 Alexey Ishchuk 2014-11-14 38 u8 local_buf[64];
4eafad7febd482 Alexey Ishchuk 2014-11-14 39 void __iomem *io_addr;
4eafad7febd482 Alexey Ishchuk 2014-11-14 40 void *buf;
4eafad7febd482 Alexey Ishchuk 2014-11-14 41 unsigned long pfn;
4eafad7febd482 Alexey Ishchuk 2014-11-14 42 long ret;
4eafad7febd482 Alexey Ishchuk 2014-11-14 43
4eafad7febd482 Alexey Ishchuk 2014-11-14 44 if (!zpci_is_enabled())
4eafad7febd482 Alexey Ishchuk 2014-11-14 45 return -ENODEV;
4eafad7febd482 Alexey Ishchuk 2014-11-14 46
4eafad7febd482 Alexey Ishchuk 2014-11-14 47 if (length <= 0 || PAGE_SIZE - (mmio_addr & ~PAGE_MASK) < length)
4eafad7febd482 Alexey Ishchuk 2014-11-14 48 return -EINVAL;
4eafad7febd482 Alexey Ishchuk 2014-11-14 49 if (length > 64) {
4eafad7febd482 Alexey Ishchuk 2014-11-14 50 buf = kmalloc(length, GFP_KERNEL);
4eafad7febd482 Alexey Ishchuk 2014-11-14 51 if (!buf)
4eafad7febd482 Alexey Ishchuk 2014-11-14 52 return -ENOMEM;
4eafad7febd482 Alexey Ishchuk 2014-11-14 53 } else
4eafad7febd482 Alexey Ishchuk 2014-11-14 54 buf = local_buf;
4eafad7febd482 Alexey Ishchuk 2014-11-14 55
4eafad7febd482 Alexey Ishchuk 2014-11-14 56 ret = get_pfn(mmio_addr, VM_WRITE, &pfn);
4eafad7febd482 Alexey Ishchuk 2014-11-14 57 if (ret)
4eafad7febd482 Alexey Ishchuk 2014-11-14 58 goto out;
eba8452525e3fd Heiko Carstens 2014-12-12 59 io_addr = (void __iomem *)((pfn << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK));
4eafad7febd482 Alexey Ishchuk 2014-11-14 60
4eafad7febd482 Alexey Ishchuk 2014-11-14 61 ret = -EFAULT;
4eafad7febd482 Alexey Ishchuk 2014-11-14 62 if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE)
4eafad7febd482 Alexey Ishchuk 2014-11-14 63 goto out;
4eafad7febd482 Alexey Ishchuk 2014-11-14 64
4eafad7febd482 Alexey Ishchuk 2014-11-14 65 if (copy_from_user(buf, user_buffer, length))
4eafad7febd482 Alexey Ishchuk 2014-11-14 66 goto out;
4eafad7febd482 Alexey Ishchuk 2014-11-14 67
f0483044c1c960 Sebastian Ott 2015-02-25 68 ret = zpci_memcpy_toio(io_addr, buf, length);
4eafad7febd482 Alexey Ishchuk 2014-11-14 69 out:
4eafad7febd482 Alexey Ishchuk 2014-11-14 70 if (buf != local_buf)
4eafad7febd482 Alexey Ishchuk 2014-11-14 71 kfree(buf);
4eafad7febd482 Alexey Ishchuk 2014-11-14 72 return ret;
4eafad7febd482 Alexey Ishchuk 2014-11-14 73 }
4eafad7febd482 Alexey Ishchuk 2014-11-14 74

:::::: The code at line 35 was first introduced by commit
:::::: 4eafad7febd482092b331ea72c37274d745956be s390/kernel: add system calls for PCI memory access

:::::: TO: Alexey Ishchuk <aishchuk@xxxxxxxxxxxxxxxxxx>
:::::: CC: Martin Schwidefsky <schwidefsky@xxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki