[PATCH] drm/debugfs: fix potential NULL pointer dereference

Dmitry Baryshkov dmitry.baryshkov at linaro.org
Tue Dec 5 13:19:56 UTC 2023


On Tue, 5 Dec 2023 at 15:06, Marek Szyprowski <m.szyprowski at samsung.com> wrote:
>
> encoder->funcs entry might be NULL, so check it first before calling its
> methods. This fixes NULL pointer dereference observed on Rasberry Pi
> 3b/4b boards.
>
> Fixes: caf525ed45b4 ("drm/encoder: register per-encoder debugfs dir")
> Signed-off-by: Marek Szyprowski <m.szyprowski at samsung.com>

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov at linaro.org>

> ---
> This fixes the following issue observed on Raspberry Pi 4b:
>
> vc4-drm gpu: bound fe400000.hvs (ops vc4_hvs_ops [vc4])
> vc4-drm gpu: bound fef00700.hdmi (ops vc4_hdmi_ops [vc4])
> vc4-drm gpu: bound fef05700.hdmi (ops vc4_hdmi_ops [vc4])
> vc4-drm gpu: bound fe004000.txp (ops vc4_txp_ops [vc4])
> vc4-drm gpu: bound fe206000.pixelvalve (ops vc4_crtc_ops [vc4])
> vc4-drm gpu: bound fe207000.pixelvalve (ops vc4_crtc_ops [vc4])
> vc4-drm gpu: bound fe20a000.pixelvalve (ops vc4_crtc_ops [vc4])
> vc4-drm gpu: bound fe216000.pixelvalve (ops vc4_crtc_ops [vc4])
> 8<--- cut here ---
> Unable to handle kernel NULL pointer dereference at virtual address 00000010 when read
> [00000010] *pgd=00000000
> Internal error: Oops: 5 [#1] SMP ARM
> Modules linked in: sha256_arm raspberrypi_hwmon cfg80211(+) hci_uart btbcm bluetooth vc4(+) ecdh_generic ecc libaes snd_soc_hdmi_codec snd_soc_core v3d drm_shmem_helper ac97_bus snd_pcm_dmaengine snd_pcm genet(+) gpu_sched snd_timer snd bcm2711_thermal soundcore drm_dma_helper
> CPU: 1 PID: 221 Comm: systemd-udevd Not tainted 6.7.0-rc4-next-20231205 #14267
> Hardware name: BCM2711
> PC is at drm_debugfs_encoder_add+0x6c/0x98
> LR is at 0x0
> ...
>  drm_debugfs_encoder_add from drm_encoder_register_all+0x20/0x60
>  drm_encoder_register_all from drm_modeset_register_all+0x34/0x70
>  drm_modeset_register_all from drm_dev_register+0x24c/0x28c
>  drm_dev_register from vc4_drm_bind+0x21c/0x2d0 [vc4]
>  vc4_drm_bind [vc4] from try_to_bring_up_aggregate_device+0x160/0x1bc
>  try_to_bring_up_aggregate_device from component_master_add_with_match+0xc4/0xf8
>  component_master_add_with_match from vc4_platform_drm_probe+0xa0/0xc0 [vc4]
>  vc4_platform_drm_probe [vc4] from platform_probe+0x5c/0xb8
>  platform_probe from really_probe+0xc8/0x2dc
>  really_probe from __driver_probe_device+0x88/0x19c
>  __driver_probe_device from driver_probe_device+0x30/0x104
>  driver_probe_device from __driver_attach+0x90/0x174
>  __driver_attach from bus_for_each_dev+0x6c/0xb4
>  bus_for_each_dev from bus_add_driver+0xcc/0x1cc
>  bus_add_driver from driver_register+0x7c/0x118
>  driver_register from vc4_drm_register+0x44/0x1000 [vc4]
>  vc4_drm_register [vc4] from do_one_initcall+0x40/0x1e0
>  do_one_initcall from do_init_module+0x50/0x1e4
>  do_init_module from init_module_from_file+0x90/0xbc
>  init_module_from_file from sys_finit_module+0x144/0x258
>  sys_finit_module from ret_fast_syscall+0x0/0x54
> Exception stack(0xf0cf1fa8 to 0xf0cf1ff0)
> ...
> ---[ end trace 0000000000000000 ]---
>
> ---
>  drivers/gpu/drm/drm_debugfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)


-- 
With best wishes
Dmitry


More information about the dri-devel mailing list