linux/drivers/gpu/drm/mediatek
Hsin-Yi Wang d2bd30c710 drm/mediatek: Fix a null pointer crash in mtk_drm_crtc_finish_page_flip
[ Upstream commit c958e86e9c ]

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: 119f517362 ("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>
History 2024-03-26 18:20:52 -04:00
..
Kconfig drm/mediatek: Add MT8195 Embedded DisplayPort driver 2022-09-04 15:32:05 +03:00
Makefile drm/mediatek: Add MT8195 Embedded DisplayPort driver 2022-09-04 15:32:05 +03:00
mtk_cec.c drm/mediatek: Fix mtk_cec_mask() 2022-04-06 22:34:28 +08:00
mtk_cec.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mtk_disp_aal.c drm/mediatek: Add lut diff flag for new gamma hardware support 2022-04-29 06:14:49 +08:00
mtk_disp_ccorr.c drm/mediatek: Add support for Mediatek SoC MT8192 2021-11-16 07:29:48 +08:00
mtk_disp_color.c drm/mediatek: Add component_del in OVL and COLOR remove function 2021-08-12 07:00:50 +08:00
mtk_disp_drv.h drm/mediatek: Add display merge start/stop API for cmdq support 2022-06-27 22:32:28 +08:00
mtk_disp_gamma.c drm/mediatek: Add lut diff flag for new gamma hardware support 2022-04-29 06:14:49 +08:00
mtk_disp_merge.c drm/mediatek: Fix underrun in VDO1 when switches off the layer 2024-01-25 15:27:35 -08:00
mtk_disp_ovl.c drm: Drop drm_blend.h from drm_crtc.h 2022-06-20 23:53:55 +03:00
mtk_disp_rdma.c Mediatek DRM Next for Linux 5.20 2022-07-12 17:01:42 +10:00
mtk_dp.c drm/mediatek: dp: Add phy_mtk_dp module as pre-dependency 2024-01-25 15:27:36 -08:00
mtk_dp_reg.h drm/mediatek: dp: Remove unused register definitions 2022-09-19 12:17:42 +03:00
mtk_dpi.c drm/mediatek: Modify dpi power on/off sequence. 2022-12-31 13:32:11 +01:00
mtk_dpi_regs.h drm/mediatek: dpi: Add dp_intf support 2022-07-06 22:51:44 +08:00
mtk_drm_crtc.c drm/mediatek: Fix a null pointer crash in mtk_drm_crtc_finish_page_flip 2024-03-26 18:20:52 -04:00
mtk_drm_crtc.h drm-misc-next for 5.13: 2021-03-16 17:08:46 +10:00
mtk_drm_ddp_comp.c drm/mediatek: Fix wrong dither settings 2022-09-13 07:10:08 +08:00
mtk_drm_ddp_comp.h drm/mediatek: dpi: Add dp_intf support 2022-07-06 22:51:44 +08:00
mtk_drm_drv.c drm/mediatek: Clean dangling pointer on bind error path 2023-03-10 09:33:17 +01:00
mtk_drm_drv.h drm/mediatek: Add display MDP RDMA support for MT8195 2022-06-27 22:24:14 +08:00
mtk_drm_gem.c drm/mediatek: Correctly free sg_table in gem prime vmap 2023-10-25 12:03:05 +02:00
mtk_drm_gem.h dma-buf-map: Rename to iosys-map 2022-02-07 16:35:35 -08:00
mtk_drm_plane.c drm/mediatek: Fix iommu fault by swapping FBs after updating plane state 2023-11-20 11:52:00 +01:00
mtk_drm_plane.h drm/mediatek: Add mediatek-drm plane color encoding info 2022-06-27 22:42:20 +08:00
mtk_dsi.c drm/mediatek: dsi: Fix DSI RGB666 formats and definitions 2024-03-26 18:20:50 -04:00
mtk_hdmi.c drm/mediatek: Fix return type of mtk_hdmi_bridge_mode_valid() 2022-12-31 13:33:01 +01:00
mtk_hdmi.h drm/mediatek: Separate mtk_hdmi_phy to an independent module 2020-09-06 07:02:54 +08:00
mtk_hdmi_ddc.c drm/mediatek: Add missing MODULE_DEVICE_TABLE() 2021-03-31 19:38:06 +08:00
mtk_hdmi_regs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mtk_mdp_rdma.c drm/mediatek: Return error if MDP RDMA failed to enable the clock 2024-01-25 15:27:35 -08:00
mtk_mdp_rdma.h drm/mediatek: Add display MDP RDMA support for MT8195 2022-06-27 22:24:14 +08:00