linux/drivers/gpu/drm/mediatek
Luca Leonardo Scorcia 4cfdfeb6ac drm/mediatek: dsi: Store driver data before invoking mipi_dsi_host_register
The call to mipi_dsi_host_register triggers a callback to mtk_dsi_bind,
which uses dev_get_drvdata to retrieve the mtk_dsi struct, so this
structure needs to be stored inside the driver data before invoking it.

As drvdata is currently uninitialized it leads to a crash when
registering the DSI DRM encoder right after acquiring
the mode_config.idr_mutex, blocking all subsequent DRM operations.

Fixes the following crash during mediatek-drm probe (tested on Xiaomi
Smart Clock x04g):

Unable to handle kernel NULL pointer dereference at virtual address
 0000000000000040
[...]
Modules linked in: mediatek_drm(+) drm_display_helper cec drm_client_lib
 drm_dma_helper drm_kms_helper panel_simple
[...]
Call trace:
 drm_mode_object_add+0x58/0x98 (P)
 __drm_encoder_init+0x48/0x140
 drm_encoder_init+0x6c/0xa0
 drm_simple_encoder_init+0x20/0x34 [drm_kms_helper]
 mtk_dsi_bind+0x34/0x13c [mediatek_drm]
 component_bind_all+0x120/0x280
 mtk_drm_bind+0x284/0x67c [mediatek_drm]
 try_to_bring_up_aggregate_device+0x23c/0x320
 __component_add+0xa4/0x198
 component_add+0x14/0x20
 mtk_dsi_host_attach+0x78/0x100 [mediatek_drm]
 mipi_dsi_attach+0x2c/0x50
 panel_simple_dsi_probe+0x4c/0x9c [panel_simple]
 mipi_dsi_drv_probe+0x1c/0x28
 really_probe+0xc0/0x3dc
 __driver_probe_device+0x80/0x160
 driver_probe_device+0x40/0x120
 __device_attach_driver+0xbc/0x17c
 bus_for_each_drv+0x88/0xf0
 __device_attach+0x9c/0x1cc
 device_initial_probe+0x54/0x60
 bus_probe_device+0x34/0xa0
 device_add+0x5b0/0x800
 mipi_dsi_device_register_full+0xdc/0x16c
 mipi_dsi_host_register+0xc4/0x17c
 mtk_dsi_probe+0x10c/0x260 [mediatek_drm]
 platform_probe+0x5c/0xa4
 really_probe+0xc0/0x3dc
 __driver_probe_device+0x80/0x160
 driver_probe_device+0x40/0x120
 __driver_attach+0xc8/0x1f8
 bus_for_each_dev+0x7c/0xe0
 driver_attach+0x24/0x30
 bus_add_driver+0x11c/0x240
 driver_register+0x68/0x130
 __platform_register_drivers+0x64/0x160
 mtk_drm_init+0x24/0x1000 [mediatek_drm]
 do_one_initcall+0x60/0x1d0
 do_init_module+0x54/0x240
 load_module+0x1838/0x1dc0
 init_module_from_file+0xd8/0xf0
 __arm64_sys_finit_module+0x1b4/0x428
 invoke_syscall.constprop.0+0x48/0xc8
 do_el0_svc+0x3c/0xb8
 el0_svc+0x34/0xe8
 el0t_64_sync_handler+0xa0/0xe4
 el0t_64_sync+0x198/0x19c
Code: 52800022 941004ab 2a0003f3 37f80040 (29005a80)

Fixes: e4732b590a ("drm/mediatek: dsi: Register DSI host after acquiring clocks and PHY")
Signed-off-by: Luca Leonardo Scorcia <l.scorcia@gmail.com>
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/20260225094047.76780-1-l.scorcia@gmail.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
2026-03-22 14:15:44 +00:00
..
Kconfig drm/mediatek: mtk_gem: Partial refactor and use drm_gem_dma_object 2026-01-18 23:47:54 +00:00
Makefile drm/mediatek: Introduce HDMI/DDC v2 for MT8195/MT8188 2025-11-17 15:04:41 +00:00
mtk_cec.c drm/mediatek: mtk_cec: Switch to register as module_platform_driver 2025-04-17 23:26:14 +00:00
mtk_cec.h
mtk_crtc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
mtk_crtc.h drm/mediatek: Add wait_event_timeout when disabling plane 2025-07-17 23:18:53 +00:00
mtk_ddp_comp.c drm/mediatek: Fix probe device leaks 2025-11-17 15:04:42 +00:00
mtk_ddp_comp.h drm/mediatek: Fix probe resource leaks 2025-11-17 15:04:41 +00:00
mtk_disp_aal.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
mtk_disp_ccorr.c drm/mediatek: Fix CCORR mtk_ctm_s31_32_to_s1_n function issue 2025-11-18 13:46:12 +00:00
mtk_disp_color.c drm/mediatek: Move to devm_platform_ioremap_resource() usage 2025-03-02 14:59:55 +00:00
mtk_disp_drv.h drm/mediatek: only announce AFBC if really supported 2025-07-17 23:19:05 +00:00
mtk_disp_gamma.c drm/mediatek: Move to devm_platform_ioremap_resource() usage 2025-03-02 14:59:55 +00:00
mtk_disp_merge.c drm/mediatek: Move to devm_platform_ioremap_resource() usage 2025-03-02 14:59:55 +00:00
mtk_disp_ovl.c drm/mediatek: only announce AFBC if really supported 2025-07-17 23:19:05 +00:00
mtk_disp_ovl_adaptor.c drm/mediatek: ovl_adaptor: Fix probe device leaks 2025-11-17 15:04:42 +00:00
mtk_disp_rdma.c drm/mediatek: Move to devm_platform_ioremap_resource() usage 2025-03-02 14:59:55 +00:00
mtk_dp.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
mtk_dp_reg.h drm/mediatek: dp: Add sdp path reset 2024-12-25 13:34:41 +00:00
mtk_dpi.c drm/mediatek: dpi: Find next bridge during probe 2026-01-18 23:31:47 +00:00
mtk_dpi_regs.h drm/mediatek: Add support for MT8195 Digital Parallel Interface 2025-03-02 14:11:09 +00:00
mtk_drm_drv.c Mediatek DRM Next - 20251120 2025-11-21 18:48:28 +10:00
mtk_drm_drv.h drm/mediatek: Implement OF graphs support for display paths 2024-10-21 12:42:25 +00:00
mtk_dsi.c drm/mediatek: dsi: Store driver data before invoking mipi_dsi_host_register 2026-03-22 14:15:44 +00:00
mtk_ethdr.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
mtk_ethdr.h drm/mediatek: Add blend_modes to mtk_plane_init() for different SoCs 2024-10-22 12:47:47 +00:00
mtk_gem.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
mtk_gem.h drm/mediatek: mtk_gem: Partial refactor and use drm_gem_dma_object 2026-01-18 23:47:54 +00:00
mtk_hdmi.c drm/mediatek: mtk_hdmi*: convert to of_drm_find_and_get_bridge() 2026-01-21 13:59:56 +01:00
mtk_hdmi_common.c Linux 6.19-rc7 2026-01-28 12:44:28 +10:00
mtk_hdmi_common.h Linux 6.19-rc7 2026-01-28 12:44:28 +10:00
mtk_hdmi_ddc.c drm/mediatek: mtk_hdmi_ddc: Switch to register as module_platform_driver 2025-04-21 12:27:55 +00:00
mtk_hdmi_ddc_v2.c drm/mediatek: mtk_hdmi_ddc_v2: Fix multi-byte writes 2025-12-30 15:59:36 +00:00
mtk_hdmi_regs.h
mtk_hdmi_regs_v2.h drm/mediatek: Introduce HDMI/DDC v2 for MT8195/MT8188 2025-11-17 15:04:41 +00:00
mtk_hdmi_v2.c Linux 6.19-rc7 2026-01-28 12:44:28 +10:00
mtk_mdp_rdma.c drm/mediatek: Move to devm_platform_ioremap_resource() usage 2025-03-02 14:59:55 +00:00
mtk_mdp_rdma.h drm/mediatek: Add display MDP RDMA support for MT8195 2022-06-27 22:24:14 +08:00
mtk_padding.c Get rid of 'remove_new' relic from platform driver struct 2024-12-01 15:12:43 -08:00
mtk_plane.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
mtk_plane.h drm/mediatek: only announce AFBC if really supported 2025-07-17 23:19:05 +00:00