From nobody Sun Feb 8 22:17:56 2026 Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) (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 CEBF22DB780 for ; Thu, 29 Jan 2026 09:05:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769677553; cv=none; b=SE2asHigU9E0ijRa3swzjXPGWGj5TugtFDUL2/Btcp7CerHeY3cUpwQ3RKVM6M7ziXEJlFvGiHfxOvhnZi6SrI6ICgZnyLl/UZ7oZCq9j7wRsjvoI4RLyLNHWyIjcABve2FdZluS5Emh4jnoUCSzYPF6PT2LeIby/GzxSz330h8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769677553; c=relaxed/simple; bh=fkkvpQzHdwJoLTTSGS4iwVU9KbnSbBGty5EQJIjvjqs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=KJD0WynDwNKM0RmqCHd28OrBGr6KVJzBKBl6ImC2bDG88UA5b+91j+pdsxxtqZ2z8eWnlBarhLVhNuuBbjfd0iw602g8pr5TCXkbhN6jNrDm42Z5fD/Jvj327OEDV27NwBnFLxGVmbgw0gmr5kDSJA+f8NKiUwE1bIEX9XVJE1Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn; spf=pass smtp.mailfrom=seu.edu.cn; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b=VUzNK6Lc; arc=none smtp.client-ip=45.254.49.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=seu.edu.cn Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=seu.edu.cn header.i=@seu.edu.cn header.b="VUzNK6Lc" Received: from LAPTOP-N070L597.localdomain (unknown [58.241.16.34]) by smtp.qiye.163.com (Hmail) with ESMTP id 32699cf23; Thu, 29 Jan 2026 17:05:45 +0800 (GMT+08:00) From: Zilin Guan To: alexander.deucher@amd.com Cc: christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch, lijo.lazar@amd.com, Hawking.Zhang@amd.com, Prike.Liang@amd.com, le.ma@amd.com, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, jianhao.xu@seu.edu.cn, Zilin Guan Subject: [PATCH] drm/amdgpu: Use kvfree instead of kfree in amdgpu_gmc_get_nps_memranges() Date: Thu, 29 Jan 2026 09:05:42 +0000 Message-Id: <20260129090542.907623-1-zilin@seu.edu.cn> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a9c0900613803a1kunm465c995a10b97f X-HM-MType: 10 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDQhkdVhkZQ0tJQxoYTE0dS1YeHw5VEwETFhoSFy QUDg9ZV1kYEgtZQVlOQ1VJT0pVSk1VSE9ZV1kWGg8SFR0UWUFZT0tIVUpLSUhOQ0NVSktLVUtZBg ++ DKIM-Signature: a=rsa-sha256; b=VUzNK6LcXpSolDCnOVEOm2cgMJ7l996ghpbKUuBVBA1gPAxZGrV5wNnJ7CmqI8w52KDanfuBnqpt9wYlkJQhgfq4QGpAKMrnyQfPlEtyh3aLfmEJxZtKizDALqWcp2LcULayLgDclOv2TCj2/WeXHuwyaiMH+aV8msZLrUPanvk=; s=default; c=relaxed/relaxed; d=seu.edu.cn; v=1; bh=ZmXJ3O1Z7fCSx2JYjXY/DoaySeq3pCLYnyjozwche5c=; h=date:mime-version:subject:message-id:from; Content-Type: text/plain; charset="utf-8" amdgpu_discovery_get_nps_info() internally allocates memory for ranges using kvcalloc(), which may use vmalloc() for large allocation. Using kfree() to release vmalloc memory will lead to a memory corruption. Use kvfree() to safely handle both kmalloc and vmalloc allocations. Compile tested only. Issue found using a prototype static analysis tool and code review. Fixes: b194d21b9bcc ("drm/amdgpu: Use NPS ranges from discovery table") Signed-off-by: Zilin Guan --- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c b/drivers/gpu/drm/amd/= amdgpu/amdgpu_gmc.c index 7e623f91f2d7..cb0d1ac148e9 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c @@ -1382,7 +1382,7 @@ int amdgpu_gmc_get_nps_memranges(struct amdgpu_device= *adev, if (!*exp_ranges) *exp_ranges =3D range_cnt; err: - kfree(ranges); + kvfree(ranges); =20 return ret; } --=20 2.34.1