]> git.hungrycats.org Git - linux/commit
drm/mediatek: Add 0 size check to mtk_drm_gem_obj
authorJustin Green <greenjustin@chromium.org>
Thu, 7 Mar 2024 18:00:51 +0000 (13:00 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 May 2024 07:49:35 +0000 (09:49 +0200)
commit9489951e3ae505534c4013db4e76b1b5a3151ac7
tree1b680862af6504f411156ed3f6123636af3d06a5
parent1ca1c5aba6291fe9b5d38a934ef8f6d4ff912cf2
drm/mediatek: Add 0 size check to mtk_drm_gem_obj

[ Upstream commit 1e4350095e8ab2577ee05f8c3b044e661b5af9a0 ]

Add a check to mtk_drm_gem_init if we attempt to allocate a GEM object
of 0 bytes. Currently, no such check exists and the kernel will panic if
a userspace application attempts to allocate a 0x0 GBM buffer.

Tested by attempting to allocate a 0x0 GBM buffer on an MT8188 and
verifying that we now return EINVAL.

Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.")
Signed-off-by: Justin Green <greenjustin@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20240307180051.4104425-1-greenjustin@chromium.org/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/mediatek/mtk_drm_gem.c