[kbuild] Re: [PATCH 1/7] vfio: iommu_type1: Clear added dirty bit when unwind pin

Dan Carpenter
2020-12-16T07:25:10Z

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

Hi Keqian,

url: https://github.com/0day-ci/linux/commits/Keqian-Zhu/vfio-iommu_type1-Some-fixes-and-optimization/20201210-154322
base: https://github.com/awilliam/linux-vfio.git next
config: x86_64-randconfig-m001-20201215 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

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

smatch warnings:
drivers/vfio/vfio_iommu_type1.c:648 vfio_iommu_type1_pin_pages() warn: variable dereferenced before check 'iommu' (see line 640)

vim +/iommu +648 drivers/vfio/vfio_iommu_type1.c

a54eb55045ae9b3 Kirti Wankhede 2016-11-17 631 static int vfio_iommu_type1_pin_pages(void *iommu_data,
95fc87b44104d9a Kirti Wankhede 2020-05-29 632 struct iommu_group *iommu_group,
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 633 unsigned long *user_pfn,
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 634 int npage, int prot,
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 635 unsigned long *phys_pfn)
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 636 {
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 637 struct vfio_iommu *iommu = iommu_data;
95fc87b44104d9a Kirti Wankhede 2020-05-29 638 struct vfio_group *group;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 639 int i, j, ret;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 @640 unsigned long pgshift = __ffs(iommu->pgsize_bitmap);
^^^^^^^^^^^^^^^^^^^^
The patch introduces a new dereference.

a54eb55045ae9b3 Kirti Wankhede 2016-11-17 641 unsigned long remote_vaddr;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 642 unsigned long bitmap_offset;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 643 unsigned long *bitmap_added;
2b172c0ea2a6daf Keqian Zhu 2020-12-10 644 dma_addr_t iova;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 645 struct vfio_dma *dma;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 646 bool do_accounting;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 647
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 @648 if (!iommu || !user_pfn || !phys_pfn)
^^^^^^
Checked too late.

a54eb55045ae9b3 Kirti Wankhede 2016-11-17 649 return -EINVAL;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 650
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 651 /* Supported for v2 version only */
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 652 if (!iommu->v2)
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 653 return -EACCES;
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 654
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 655 mutex_lock(&iommu->lock);
a54eb55045ae9b3 Kirti Wankhede 2016-11-17 656

---
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: 38446 bytes --]

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

[-- Attachment #4: Type: text/plain, Size: 176 bytes --]