drivers/iommu/iommufd/device.c:327 iommufd_sw_msi_get_map() error: 'cur' dereferencing possible ERR_PTR()
kernel test robot
build botBCC: [email protected]
CC: [email protected]
TO: Jason Gunthorpe <[email protected]>
CC: Nicolin Chen <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 8433c776e1eb1371f5cd40b5fd3a61f9c7b7f3ad commit: 598749522d4254afb33b8a6c1bea614a95896868 [4924/6583] iommufd: Implement sw_msi support natively
:::::: branch date: 24 hours ago
:::::: commit date: 6 days ago
config: i386-randconfig-141-20250226 (https://download.01.org/0day-ci/archive/20250227/[email protected]/config)
compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90)
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 <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
New smatch warnings:drivers/iommu/iommufd/device.c:327 iommufd_sw_msi_get_map() error: 'cur' dereferencing possible ERR_PTR()
Old smatch warnings:drivers/iommu/iommufd/device.c:1392 iommufd_access_rw() error: uninitialized symbol 'rc'.
vim +/cur +327 drivers/iommu/iommufd/device.c
78d3df457ae5eb Yi Liu 2023-07-18 296
598749522d4254 Jason Gunthorpe 2025-02-19 297 /*
598749522d4254 Jason Gunthorpe 2025-02-19 298 * Get a iommufd_sw_msi_map for the msi physical address requested by the irq
598749522d4254 Jason Gunthorpe 2025-02-19 299 * layer. The mapping to IOVA is global to the iommufd file descriptor, every
598749522d4254 Jason Gunthorpe 2025-02-19 300 * domain that is attached to a device using the same MSI parameters will use
598749522d4254 Jason Gunthorpe 2025-02-19 301 * the same IOVA.
598749522d4254 Jason Gunthorpe 2025-02-19 302 */
598749522d4254 Jason Gunthorpe 2025-02-19 303 static __maybe_unused struct iommufd_sw_msi_map *
598749522d4254 Jason Gunthorpe 2025-02-19 304 iommufd_sw_msi_get_map(struct iommufd_ctx *ictx, phys_addr_t msi_addr,
598749522d4254 Jason Gunthorpe 2025-02-19 305 phys_addr_t sw_msi_start)
598749522d4254 Jason Gunthorpe 2025-02-19 306 {
598749522d4254 Jason Gunthorpe 2025-02-19 307 struct iommufd_sw_msi_map *cur;
598749522d4254 Jason Gunthorpe 2025-02-19 308 unsigned int max_pgoff = 0;
598749522d4254 Jason Gunthorpe 2025-02-19 309
598749522d4254 Jason Gunthorpe 2025-02-19 310 lockdep_assert_held(&ictx->sw_msi_lock);
598749522d4254 Jason Gunthorpe 2025-02-19 311
598749522d4254 Jason Gunthorpe 2025-02-19 312 list_for_each_entry(cur, &ictx->sw_msi_list, sw_msi_item) {
598749522d4254 Jason Gunthorpe 2025-02-19 313 if (cur->sw_msi_start != sw_msi_start)
598749522d4254 Jason Gunthorpe 2025-02-19 314 continue;
598749522d4254 Jason Gunthorpe 2025-02-19 315 max_pgoff = max(max_pgoff, cur->pgoff + 1);
598749522d4254 Jason Gunthorpe 2025-02-19 316 if (cur->msi_addr == msi_addr)
598749522d4254 Jason Gunthorpe 2025-02-19 317 return cur;
598749522d4254 Jason Gunthorpe 2025-02-19 318 }
598749522d4254 Jason Gunthorpe 2025-02-19 319
598749522d4254 Jason Gunthorpe 2025-02-19 320 if (ictx->sw_msi_id >=
598749522d4254 Jason Gunthorpe 2025-02-19 321 BITS_PER_BYTE * sizeof_field(struct iommufd_sw_msi_maps, bitmap))
598749522d4254 Jason Gunthorpe 2025-02-19 322 return ERR_PTR(-EOVERFLOW);
598749522d4254 Jason Gunthorpe 2025-02-19 323
598749522d4254 Jason Gunthorpe 2025-02-19 324 cur = kzalloc(sizeof(*cur), GFP_KERNEL);
598749522d4254 Jason Gunthorpe 2025-02-19 325 if (!cur)
598749522d4254 Jason Gunthorpe 2025-02-19 326 cur = ERR_PTR(-ENOMEM);
598749522d4254 Jason Gunthorpe 2025-02-19 @327 cur->sw_msi_start = sw_msi_start;
598749522d4254 Jason Gunthorpe 2025-02-19 328 cur->msi_addr = msi_addr;
598749522d4254 Jason Gunthorpe 2025-02-19 329 cur->pgoff = max_pgoff;
598749522d4254 Jason Gunthorpe 2025-02-19 330 cur->id = ictx->sw_msi_id++;
598749522d4254 Jason Gunthorpe 2025-02-19 331 list_add_tail(&cur->sw_msi_item, &ictx->sw_msi_list);
598749522d4254 Jason Gunthorpe 2025-02-19 332 return cur;
598749522d4254 Jason Gunthorpe 2025-02-19 333 }598749522d4254 Jason Gunthorpe 2025-02-19 334
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki