drm/gem: Handle shadow plane state allocation failure
Subsystems (2)
PATCH 1/1 drm/gem: Handle shadow plane state allocation failure
Allocate the new shadow plane state before destroying the existing state, so that an allocation failure leaves the current state intact.
--- drivers/gpu/drm/drm_gem_atomic_helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_atomic_helper.c +4 -2
@@ -308,14 +308,16 @@ EXPORT_SYMBOL(__drm_gem_reset_shadow_plane);*/ void drm_gem_reset_shadow_plane (struct drm_plane *plane) { -struct drm_shadow_plane_state *shadow_plane_state; +struct drm_shadow_plane_state *shadow_plane_state =kzalloc_obj (*shadow_plane_state); + +if (!shadow_plane_state) +return ;if (plane->state) {drm_gem_destroy_shadow_plane_state (plane, plane->state); plane->state =NULL ;/* must be set to NULL here */ } - shadow_plane_state =kzalloc_obj (*shadow_plane_state);__drm_gem_reset_shadow_plane (plane, shadow_plane_state); }EXPORT_SYMBOL (drm_gem_reset_shadow_plane);
Signature · 1 line
2.53.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Returning early on allocation failure in `drm_gem_reset_shadow_plane` leaves the old plane state…
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Returning early on allocation failure in drm_gem_reset_shadow_plane leaves the old plane state intact, violating DRM atomic reset semantics and causing state desynchronization. --
--- Patch [1]: [PATCH] drm/gem: Handle shadow plane state allocation failure --- commit 0d95f6bd3cf4e9b3b32636265a7263dcbf12db13
Author: Triet Hoang <[email protected]>
drm/gem: Handle shadow plane state allocation failure
Allocate the new shadow plane state before destroying the existing state, so that an allocation failure leaves the current state intact.
drivers/gpu/drm/drm_gem_atomic_helper.c EXPORT_SYMBOL(__drm_gem_reset_shadow_plane); · line 314
Quoted 12 lines
drivers/gpu/drm/drm_gem_atomic_helper.c +4
-1@@ -308,14 +308,16 @@ EXPORT_SYMBOL(__drm_gem_reset_shadow_plane);*/ void drm_gem_reset_shadow_plane (struct drm_plane *plane) { -struct drm_shadow_plane_state *shadow_plane_state; +struct drm_shadow_plane_state *shadow_plane_state =kzalloc_obj (*shadow_plane_state); + +if (!shadow_plane_state) +return ;
[Severity: High]
Does returning early here violate DRM atomic reset semantics?
The .reset hook must completely clear the software state to mirror the hardware reset (which defaults to disabled). By returning early on allocation failure, the old plane->state is left intact.
Could this cause the plane's software state to become desynchronized from both the hardware and other DRM objects (like CRTCs, which will have their state cleared)?
Subsequent atomic commits might then operate on this broken software state (e.g., a plane pointing to a disabled CRTC), causing validation failures or crashes.
Quoted 5 lines
drivers/gpu/drm/drm_gem_atomic_helper.c +0
-0if (plane->state) {drm_gem_destroy_shadow_plane_state (plane, plane->state); plane->state =NULL ;/* must be set to NULL here */ }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Thomas Zimmermann
maintainerHi,
the whole reset mechanism has never worked well IMHO. Maxime currently reworks it entirely. Not sure if we meanwhile want to paper over the reset issue.
Best regards
Thomas
Am 16.08.26 um 18:58 schrieb Triet Hoang:
Quoted 31 lines
Allocate the new shadow plane state before destroying the existing state, so that an allocation failure leaves the current state intact.
Signed-off-by Triet Hoang <[email protected]>--- drivers/gpu/drm/drm_gem_atomic_helper.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_gem_atomic_helper.c +4
-2@@ -308,14 +308,16 @@ EXPORT_SYMBOL(__drm_gem_reset_shadow_plane);*/ void drm_gem_reset_shadow_plane (struct drm_plane *plane) { -struct drm_shadow_plane_state *shadow_plane_state; +struct drm_shadow_plane_state *shadow_plane_state =kzalloc_obj (*shadow_plane_state); + +if (!shadow_plane_state) +return ;if (plane->state) {drm_gem_destroy_shadow_plane_state (plane, plane->state); plane->state =NULL ;/* must be set to NULL here */ } - shadow_plane_state =kzalloc_obj (*shadow_plane_state);__drm_gem_reset_shadow_plane (plane, shadow_plane_state); }EXPORT_SYMBOL (drm_gem_reset_shadow_plane);
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, (HRB 36809, AG Nürnberg)