[lvc-project] [QUESTION] drm/crtc: precondition for drm_crtc_init_with_planes()

Maxime Ripard mripard at kernel.org
Fri Aug 25 14:03:27 MSK 2023


On Fri, Aug 25, 2023 at 01:18:46PM +0300, e.orlova at ispras.ru 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://linuxtesting.org/pipermail/lvc-project/attachments/20230825/c00f8123/attachment.pgp>


More information about the lvc-project mailing list