Skip to content

Commit 5bf1e3b

Browse files
ruanjinjie-engChun-Kuang Hu
authored andcommitted
drm/mediatek: mtk_drm_crtc: Add checks for devm_kcalloc
As the devm_kcalloc may return NULL, the return value needs to be checked to avoid NULL poineter dereference. Fixes: 31c5558 ("drm/mediatek: Refactor plane init") Signed-off-by: ruanjinjie <ruanjinjie@huawei.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://patchwork.kernel.org/project/linux-mediatek/patch/20221205095115.2905090-1-ruanjinjie@huawei.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent 4deef81 commit 5bf1e3b

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,8 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
945945

946946
mtk_crtc->planes = devm_kcalloc(dev, num_comp_planes,
947947
sizeof(struct drm_plane), GFP_KERNEL);
948+
if (!mtk_crtc->planes)
949+
return -ENOMEM;
948950

949951
for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) {
950952
ret = mtk_drm_crtc_init_comp_planes(drm_dev, mtk_crtc, i,

0 commit comments

Comments
 (0)