[linux-next:master 12839/13846] drivers/gpu/tests/gpu_buddy_test.c:1462 gpu_test_buddy_addr_to_block() warn: passing zero to 'PTR_ERR'

kernel test robot <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <[email protected]>
BCC: [email protected]
CC: [email protected]
TO: Tejas Upadhyay <[email protected]>
CC: Arunpravin Paneer Selvam <[email protected]>
CC: Matthew Auld <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   6b8c8af514d739d0335f5579b585e02babe8a727
commit: 3de014f7debc7162ae26db2f6151af1ba5456dc0 [12839/13846] gpu/tests/gpu_buddy: Add KUnit test for gpu_buddy_allocated_addr_to_block
:::::: branch date: 3 days ago
:::::: commit date: 4 days ago
config: m68k-randconfig-r071-20260810 (https://download.01.org/0day-ci/archive/20260811/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 9.5.0
smatch: v0.5.0-9187-g5189e3fb

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]/

smatch warnings:
drivers/gpu/tests/gpu_buddy_test.c:1462 gpu_test_buddy_addr_to_block() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +1462 drivers/gpu/tests/gpu_buddy_test.c

dc0e3aa54eaa4f drivers/gpu/drm/tests/drm_buddy_test.c Sanjay Yadav   2026-01-08  1424  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1425  static void gpu_test_buddy_addr_to_block(struct kunit *test)
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1426  {
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1427  	struct gpu_buddy_block *allocated_block, *found_block;
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1428  	LIST_HEAD(allocated_list);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1429  	const u64 test_size = SZ_4M + SZ_2M;
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1430  	const u64 alloc_start = SZ_4M;
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1431  	const u64 alloc_size = SZ_4K;
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1432  	const u64 chunk_size = SZ_4K;
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1433  	struct gpu_buddy mm;
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1434  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1435  	KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_init(&mm, test_size, chunk_size),
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1436  			       "buddy_init failed\n");
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1437  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1438  	KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_alloc_blocks(&mm, alloc_start,
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1439  							    alloc_start + alloc_size,
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1440  							    alloc_size, chunk_size,
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1441  							    &allocated_list, 0),
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1442  			       "buddy_alloc failed\n");
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1443  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1444  	allocated_block = list_first_entry(&allocated_list, struct gpu_buddy_block, link);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1445  	KUNIT_EXPECT_EQ(test, gpu_buddy_block_offset(allocated_block), alloc_start);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1446  	KUNIT_EXPECT_EQ(test, gpu_buddy_block_size(&mm, allocated_block), alloc_size);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1447  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1448  	found_block = gpu_buddy_allocated_addr_to_block(&mm, alloc_start);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1449  	KUNIT_EXPECT_PTR_EQ(test, found_block, allocated_block);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1450  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1451  	/* Unaligned address inside the allocated block (should resolve to the same block) */
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1452  	found_block = gpu_buddy_allocated_addr_to_block(&mm, alloc_start + 16);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1453  	KUNIT_EXPECT_PTR_EQ(test, found_block, allocated_block);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1454  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1455  	/* An unallocated address inside the manager should return NULL. */
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1456  	found_block = gpu_buddy_allocated_addr_to_block(&mm,
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1457  							alloc_start - chunk_size);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1458  	KUNIT_EXPECT_NULL(test, found_block);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1459  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1460  	/* An address outside the manager should return -ENXIO. */
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1461  	found_block = gpu_buddy_allocated_addr_to_block(&mm, test_size);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06 @1462  	KUNIT_EXPECT_EQ(test, PTR_ERR(found_block), -ENXIO);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1463  
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1464  	/* 3. Standard inline cleanup flow */
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1465  	gpu_buddy_free_list(&mm, &allocated_list, 0);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1466  	gpu_buddy_fini(&mm);
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1467  }
3de014f7debc71 drivers/gpu/tests/gpu_buddy_test.c     Tejas Upadhyay 2026-08-06  1468  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.