Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/tidss: crtc: Cleanup reset implementation

The tidss_crtc_reset() function will (rightfully) destroy any
pre-existing state.

However, the tidss CRTC driver has its own CRTC state structure that
subclasses drm_crtc_state, and yet will destroy the previous state
by calling __drm_atomic_helper_crtc_destroy_state() and kfree() on its
drm_crtc_state pointer.

It works only because the drm_crtc_state is the first field in the
structure, and thus its offset is 0. It's incredibly fragile however, so
let's call our destroy implementation in such a case to deal with it
properly.

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://lore.kernel.org/r/20250902-drm-state-readout-v1-22-14ad5315da3f@kernel.org
Signed-off-by: Maxime Ripard <mripard@kernel.org>
Link: https://lore.kernel.org/r/20250902-drm-state-readout-v1-22-14ad5315da3f@kernel.org

+1 -3
+1 -3
drivers/gpu/drm/tidss/tidss_crtc.c
··· 357 357 struct tidss_crtc_state *tstate; 358 358 359 359 if (crtc->state) 360 - __drm_atomic_helper_crtc_destroy_state(crtc->state); 361 - 362 - kfree(crtc->state); 360 + tidss_crtc_destroy_state(crtc, crtc->state); 363 361 364 362 tstate = kzalloc(sizeof(*tstate), GFP_KERNEL); 365 363 if (!tstate) {