Skip to content

Commit 1e43500

Browse files
Justin GreenChun-Kuang Hu
authored andcommitted
drm/mediatek: Add 0 size check to mtk_drm_gem_obj
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: 119f517 ("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>
1 parent 60cb97c commit 1e43500

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/gpu/drm/mediatek/mtk_drm_gem.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ static struct mtk_drm_gem_obj *mtk_drm_gem_init(struct drm_device *dev,
3838

3939
size = round_up(size, PAGE_SIZE);
4040

41+
if (size == 0)
42+
return ERR_PTR(-EINVAL);
43+
4144
mtk_gem_obj = kzalloc(sizeof(*mtk_gem_obj), GFP_KERNEL);
4245
if (!mtk_gem_obj)
4346
return ERR_PTR(-ENOMEM);

0 commit comments

Comments
 (0)