Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] Memory leak on KUnit assertion failure due to bypassed cleanup. --
--- Patch [2]: [PATCH V4 2/2] gpu/tests/gpu_buddy: Add KUnit test for gpu_buddy_allocated_addr_to_block --- commit 429e209c9177a128187845522d6b4613f6fbe30b Author: Tejas Upadhyay <[email protected]> gpu/tests/gpu_buddy: Add KUnit test for gpu_buddy_allocated_addr_to_block This patch adds a new KUnit test gpu_test_buddy_addr_to_block() to validate the gpu_buddy_allocated_addr_to_block() helper function. The test verifies exact address matching, unallocated addresses within the manager, and addresses outside the manager bounds. > diff --git a/drivers/gpu/tests/gpu_buddy_test.c > b/drivers/gpu/tests/gpu_buddy_test.c > index 89698563c61b2..5860bfc84a25a 100644 > --- a/drivers/gpu/tests/gpu_buddy_test.c > +++ b/drivers/gpu/tests/gpu_buddy_test.c > @@ -1422,6 +1422,50 @@ static void > gpu_test_buddy_alloc_exceeds_max_order(struct kunit *test) > gpu_buddy_fini(&mm); > } > > +static void gpu_test_buddy_addr_to_block(struct kunit *test) > +{ > + struct gpu_buddy_block *allocated_block, *found_block; > + LIST_HEAD(allocated_list); > + const u64 test_size = SZ_4M + SZ_2M; > + const u64 alloc_start = SZ_4M; > + const u64 alloc_size = SZ_4K; > + const u64 chunk_size = SZ_4K; > + struct gpu_buddy mm; > + > + KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_init(&mm, test_size, chunk_size), > + "buddy_init failed\n"); > + > + KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_alloc_blocks(&mm, alloc_start, > + alloc_start + > alloc_size, > + alloc_size, > chunk_size, > + &allocated_list, 0), > + "buddy_alloc failed\n"); [Severity: Medium] Will this leak memory if the allocation fails? KUNIT_ASSERT_FALSE_MSG() aborts the test execution immediately on failure, bypassing the gpu_buddy_fini(&mm) cleanup call at the end of the function. This would leak the memory allocated by gpu_buddy_init(). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
