]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
drm/msm: fix missing NULL check after kcalloc in crashstate_get_bos()
authorHuiwen He <hehuiwen@kylinos.cn>
Wed, 12 Nov 2025 17:19:47 +0000 (01:19 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:03 +0000 (14:03 +0100)
commit966fcbb8c80318aa581e97da32056ffbab6138fe
tree5ad113b0296a9a3e080b0134fe2b3a9acb8551a3
parent0bc9149da210df7e9a191dde246b89d9ad23be8a
drm/msm: fix missing NULL check after kcalloc in crashstate_get_bos()

[ Upstream commit 3065e6a4d3594b42dae6176b3e2c0c3563cf94b8 ]

The crashstate_get_bos() function allocates memory for `state->bos`
using kcalloc(), but the vmbind path does not check for allocation
failure before dereferencing it in the following drm_gpuvm_for_each_va()
loop. This could lead to a NULL pointer dereference if memory allocation
fails.

Fix this by wrapping the drm_gpuvm_for_each_va() loop with a NULL check
on state->bos, similar to the safety check in the non-vmbind path.

Fixes: af9aa6f316b3d ("drm/msm: Crashdump support for sparse")
Signed-off-by: Huiwen He <hehuiwen@kylinos.cn>
Patchwork: https://patchwork.freedesktop.org/patch/687556/
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/msm/msm_gpu.c