From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D09B38AC78 for ; Wed, 13 May 2026 08:26:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660791; cv=none; b=r/+noVHRXnLX6pvxvp5NUp5PfJiwEL8dmVEQyWnOcRl7ud4QIu33bboINe82u21epzBBt8reFPzOIY+SoQG2xEQHzap49cCABNtk6qGUEgR3xeILIP1InvEOrE6mWWXrNUsJVlxSkLZgNAmHKciOzU1wBPzv8isv8zkTYo4dpPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778660791; c=relaxed/simple; bh=k6t+YBDVrMnTwV3ia7dpAE64mdz5n6vn2s5z9gtbtmQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=dusie7jNaLQdF7iYPwKQdahsGig4Jm00YayavicvE70UbMW9oIS6xwrHa+UR4reoENAen3ojvy1WfMUzrhoBvBugbYvALDfc60km35K2KP54bNaW2ikpEXcC7snnB+7BoLKfOn2ny+OpfK79VEzo1bkH0rV6bpz/qFWYMGofQ5c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=om2Rft3k; arc=none smtp.client-ip=91.218.175.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="om2Rft3k" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1778660780; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8szn6appTCu89brk1myblNGatYqlSWNvLHOiLLGF2Fw=; b=om2Rft3kNnNHSL7dKKvoXnqVLuMpayATk81CUdJj4s/U/XIz+Cu9ddtY1dvKux1OgZptGH 2Hce1Vl+b9DFkdpDO/GZbcBqH6LuLi/CQ4u/7CIiPrkr+jnayFxwVa7HttEqztYYRNZCXE EYIkjqgcz79c6CcWhIoJ7eRbBEu3JRs= From: Hao Ge To: Jason Gunthorpe , Leon Romanovsky , Andrew Morton , Balbir Singh Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Hao Ge Subject: [PATCH] lib/test_hmm: use kvfree() to free kvcalloc() allocations Date: Wed, 13 May 2026 16:25:25 +0800 Message-Id: <20260513082525.154036-1-hao.ge@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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 --- 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; } -- 2.25.1