lib/test_hmm: use kvfree() to free kvcalloc() allocations
PATCH 1/1 lib/test_hmm: use kvfree() to free kvcalloc() allocations
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().
--- lib/test_hmm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/test_hmm.c +2 -2
@@ -1253,8 +1253,8 @@ static int dmirror_migrate_to_device(struct dmirror *dmirror,mmap_read_unlock (mm);mmput (mm); free_mem: -kfree (src_pfns); -kfree (dst_pfns); +kvfree (src_pfns); +kvfree (dst_pfns);return ret; }
Signature · 1 line
2.25.1
Quoted 20 lines · Hao Ge
Coccinelle
scripts/coccinelle/api/kfree_mismatch.coccireports 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()withkvfree()to correctly handle thevmalloc()fallback path ofkvcalloc().Fixes 775465fd26a3 ("lib/test_hmm: add zone device private THP test infrastructure")Signed-off-by Hao Ge <[email protected]>--- lib/test_hmm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)lib/test_hmm.c +0
-0
lib/test_hmm.c static int dmirror_migrate_to_device(struct dmirror *dmirror, · line 1260
Quoted 10 lines
lib/test_hmm.c +2
-2@@ -1253,8 +1253,8 @@ static int dmirror_migrate_to_device(struct dmirror *dmirror,mmap_read_unlock (mm);mmput (mm); free_mem: -kfree (src_pfns); -kfree (dst_pfns); +kvfree (src_pfns); +kvfree (dst_pfns);return ret; }
Yep. makes sense!
Thanks!
Balbir