Re: [QUESTION] drm/crtc: precondition for drm_crtc_init_with_planes()

From: Maxime Ripard
Date: Fri Aug 25 2023 - 07:04:24 EST


On Fri, Aug 25, 2023 at 01:18:46PM +0300, e.orlova@xxxxxxxxx wrote:
> Documentation for drm_crtc_init_with_planes() in
> drivers/gpu/drm/drm_crtc.c states: «The crtc structure should not be
> allocated with devm_kzalloc()».
>
> However, in drivers/gpu/drm/stm/ltdc.c
> the 2nd argument of the function drm_crtc_init_with_planes()
> is a structure allocated with devm_kzalloc()
>
> Also, in
> drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.c
> drivers/gpu/drm/logicvc/logicvc_crtc.c
> drivers/gpu/drm/meson/meson_crtc.c
> drivers/gpu/drm/mxsfb/lcdif_kms.c
> drivers/gpu/drm/mxsfb/mxsfb_kms.c
> drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c
> drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> drivers/gpu/drm/rockchip/rockchip_drm_vop2.c
> drivers/gpu/drm/sun4i/sun4i_crtc.c
> drivers/gpu/drm/tegra/dc.c
> drivers/gpu/drm/tilcdc/tilcdc_crtc.c
> the 2nd argument of the function drm_crtc_init_with_planes()
> is a field of the structure allocated with devm_kzalloc()
>
> Is it correct or can it lead to any problems?

It can lead to use-after-free issues, that's why there's that comment :)

Maxime

Attachment: signature.asc
Description: PGP signature