Commit cf7ceb37 authored by Stuart Lee's avatar Stuart Lee Committed by Peng Zhang
Browse files

drm/mediatek: Fix access violation in mtk_drm_crtc_dma_dev_get

stable inclusion
from stable-v6.6.8
commit 03e63e497a404f444f5af25e120739da3a4f03ff
bugzilla: https://gitee.com/openeuler/kernel/issues/I99K53

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=03e63e497a404f444f5af25e120739da3a4f03ff



--------------------------------

commit b6961d187fcd138981b8707dac87b9fcdbfe75d1 upstream.

Add error handling to check NULL input in
mtk_drm_crtc_dma_dev_get function.

While display path is not configured correctly, none of crtc is
established. So the caller of mtk_drm_crtc_dma_dev_get may pass
input parameter *crtc as NULL, Which may cause coredump when
we try to get the container of NULL pointer.

Fixes: cb1d6bcc ("drm/mediatek: Add dma dev get function")
Signed-off-by: default avatarStuart Lee <stuart.lee@mediatek.com>
Cc: stable@vger.kernel.org
Reviewed-by: default avatarAngeloGioacchino DEl Regno <angelogioacchino.delregno@collabora.com>
Tested-by: default avatarMacpaul Lin <macpaul.lin@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20231110012914.14884-2-stuart.lee@mediatek.com/


Signed-off-by: default avatarChun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent 57ec0068
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -885,7 +885,14 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev,

struct device *mtk_drm_crtc_dma_dev_get(struct drm_crtc *crtc)
{
	struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
	struct mtk_drm_crtc *mtk_crtc = NULL;

	if (!crtc)
		return NULL;

	mtk_crtc = to_mtk_crtc(crtc);
	if (!mtk_crtc)
		return NULL;

	return mtk_crtc->dma_dev;
}