[Intel-gfx] [PATCHv2] drm/i915: free crtc on driver remove

Murthy, Arun R arun.r.murthy at intel.com
Thu Jun 30 09:03:27 UTC 2022


> > intel_crtc is being allocated as part of intel_modeset_init_nogem and
> > not freed as part of driver remove. This will lead to memory leak.
> > Hence free up the allocated crtc on driver remove as part of
> > intel_modeset_driver_remove_nogem.
> 
> No, there's no leak and this is not needed.
> 
> See drm_mode_config_cleanup() calling crtc->funcs->destroy() on each crtc.

Sorry, I didn't notice this function.

intel_crtc_alloc() is called as part of probe->intel_modeset_init_nogem->intel_crtc_init
on similar basis cleanup/free should be done in  driver
remove->intel_modeset_driver_remove_nogem->intel_crtc_free

Does this look cleaner?

Kfree(crtc) which is called in crtc->funcs->destroy is intended for cleanup and hence
drm_crtc_cleanup() is being called from intel_crtc_destroy(). The comments added in
drm_crtc_funcs say that cleanup resources on destroy.

Again looking at the driver design, intel_crtc_alloc is not done as part of any 
drm_crtc_funcs, rather on probe->modeset_init_nogem, so calling intel_crtc_free
from remove->modeset_driver_remove_nogem would make more sence.

Also, looking into the func intel_modeset_init_nogem(), the func intel_modeset_driver_remove_nogem
should be renamed as intel_modeset_deinit_nogem().

Thanks and Regards,
Arun R Murthy
--------------------


More information about the Intel-gfx mailing list