kernel_samsung_a53x/drivers/gpu/drm/mediatek
Hsin-Yi Wang 4fd31625e1 drm/mediatek: Fix a null pointer crash in mtk_drm_crtc_finish_page_flip
[ Upstream commit c958e86e9cc1b48cac004a6e245154dfba8e163b ]

It's possible that mtk_crtc->event is NULL in
mtk_drm_crtc_finish_page_flip().

pending_needs_vblank value is set by mtk_crtc->event, but in
mtk_drm_crtc_atomic_flush(), it's is not guarded by the same
lock in mtk_drm_finish_page_flip(), thus a race condition happens.

Consider the following case:

CPU1                              CPU2
step 1:
mtk_drm_crtc_atomic_begin()
mtk_crtc->event is not null,
                                  step 1:
                                  mtk_drm_crtc_atomic_flush:
                                  mtk_drm_crtc_update_config(
                                      !!mtk_crtc->event)
step 2:
mtk_crtc_ddp_irq ->
mtk_drm_finish_page_flip:
lock
mtk_crtc->event set to null,
pending_needs_vblank set to false
unlock
                                  pending_needs_vblank set to true,

                                  step 2:
                                  mtk_crtc_ddp_irq ->
                                  mtk_drm_finish_page_flip called again,
                                  pending_needs_vblank is still true
                                  //null pointer

Instead of guarding the entire mtk_drm_crtc_atomic_flush(), it's more
efficient to just check if mtk_crtc->event is null before use.

Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC MT8173.")
Signed-off-by: Hsin-Yi Wang <hsinyi@chromium.org>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20240223212404.3709690-1-hsinyi@chromium.org/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-19 08:44:55 +01:00
..
Kconfig Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_cec.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_cec.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_disp_color.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_disp_ovl.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_disp_rdma.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_dpi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_dpi_regs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_crtc.c drm/mediatek: Fix a null pointer crash in mtk_drm_crtc_finish_page_flip 2024-11-19 08:44:55 +01:00
mtk_drm_crtc.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_ddp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_ddp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_ddp_comp.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_ddp_comp.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_drv.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_drv.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_gem.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_gem.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_plane.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_drm_plane.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_dsi.c drm/mediatek: dsi: Fix DSI RGB666 formats and definitions 2024-11-19 08:44:54 +01:00
mtk_hdmi.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_hdmi.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_hdmi_ddc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_hdmi_regs.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_mipi_tx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_mipi_tx.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_mt8173_mipi_tx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
mtk_mt8183_mipi_tx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00