From: Balbir Singh <balbirs@nvidia.com>
To: Hao Ge <hao.ge@linux.dev>, Jason Gunthorpe <jgg@ziepe.ca>,
Leon Romanovsky <leon@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/test_hmm: use kvfree() to free kvcalloc() allocations
Date: Wed, 13 May 2026 20:28:06 +1000 [thread overview]
Message-ID: <a03c93a4-9847-48fc-b82a-2fec72a292d2@nvidia.com> (raw)
In-Reply-To: <20260513082525.154036-1-hao.ge@linux.dev>
On 5/13/26 18:25, Hao Ge wrote:
> 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().
>
> Fixes: 775465fd26a3 ("lib/test_hmm: add zone device private THP test infrastructure")
> Signed-off-by: Hao Ge <hao.ge@linux.dev>
> ---
> lib/test_hmm.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index 213504915737..38996c4baa40 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -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!
Acked-by: Balbir Singh <balbirs@nvidia.com>
Thanks!
Balbir
prev parent reply other threads:[~2026-05-13 10:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-13 8:25 [PATCH] lib/test_hmm: use kvfree() to free kvcalloc() allocations Hao Ge
2026-05-13 10:28 ` Balbir Singh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a03c93a4-9847-48fc-b82a-2fec72a292d2@nvidia.com \
--to=balbirs@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=hao.ge@linux.dev \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox