]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lib/test_hmm: use kvfree() to free kvcalloc() allocations
authorHao Ge <hao.ge@linux.dev>
Wed, 13 May 2026 08:25:25 +0000 (16:25 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 2 Jun 2026 22:22:17 +0000 (15:22 -0700)
Coccinelle scripts/coccinelle/api/kfree_mismatch.cocci reports
the following warnings:

  lib/test_hmm.c:1256:15-16: WARNING kvmalloc is used to allocate this memory at line 1191
  lib/test_hmm.c:1257:15-16: WARNING kvmalloc is used to allocate this memory at line 1196

Fix this by replacing kfree() with kvfree() to correctly handle the
vmalloc() fallback path of kvcalloc().

Link: https://lore.kernel.org/20260513082525.154036-1-hao.ge@linux.dev
Fixes: 775465fd26a3 ("lib/test_hmm: add zone device private THP test infrastructure")
Signed-off-by: Hao Ge <hao.ge@linux.dev>
Acked-by: Balbir Singh <balbirs@nvidia.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Leon Romanovsky <leon@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/test_hmm.c

index 2135049157372993f44a0b2c6205c625aec105f9..38996c4baa40801396bd3b5e7037c8ad2e1369b0 100644 (file)
@@ -1253,8 +1253,8 @@ out:
        mmap_read_unlock(mm);
        mmput(mm);
 free_mem:
-       kfree(src_pfns);
-       kfree(dst_pfns);
+       kvfree(src_pfns);
+       kvfree(dst_pfns);
        return ret;
 }