Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] malidp_plane_create_state() improperly retains legacy state destruction 
logic and mutates the plane object
--

--- Patch [41]: [PATCH 41/60] drm/malidp: Convert to atomic_create_state ---
commit 22a3f18af7981b36b8b4da5e3e62def563f0192e
Author: Maxime Ripard <[email protected]>

drm/malidp: Convert to atomic_create_state

This commit converts the plane reset implementation in the malidp driver to
use atomic_create_state. The conversion was primarily done using a Coccinelle
semantic patch.

> diff --git a/drivers/gpu/drm/arm/malidp_planes.c 
> b/drivers/gpu/drm/arm/malidp_planes.c
> index 60b3f2bb153b5..82a75591a4597 100644
> --- a/drivers/gpu/drm/arm/malidp_planes.c
> +++ b/drivers/gpu/drm/arm/malidp_planes.c

[ ... ]

> @@ -73,7 +73,7 @@
>   * allocate a new empty object. We just need enough space to store
>   * a malidp_plane_state instead of a drm_plane_state.
>   */
> -static void malidp_plane_reset(struct drm_plane *plane)
> +static struct drm_plane_state *malidp_plane_create_state(struct drm_plane 
> *plane)
>  {
>       struct malidp_plane_state *state = to_malidp_plane_state(plane->state);
>  
> @@ -82,8 +82,12 @@ static void malidp_plane_reset(struct drm_plane *plane)
>       kfree(state);
>       plane->state = NULL;

[Severity: Low]
Should this legacy state destruction logic be removed from
malidp_plane_create_state()?

It appears the Coccinelle script missed this teardown logic because it checks
the local variable if (state) rather than if (plane->state) when attempting
to drop destruction calls.

The DRM core guarantees plane->state is NULL before calling
.atomic_create_state(), so this destruction logic evaluates as dead code.

Additionally, the assignment to plane->state = NULL here technically violates
the .atomic_create_state API contract, which forbids mutating the plane
object's state pointer.

>       state = kzalloc_obj(*state);
> -     if (state)
> -             __drm_atomic_helper_plane_reset(plane, &state->base);
> +     if (!state)
> +             return ERR_PTR(-ENOMEM);
> +
> +     __drm_atomic_helper_plane_state_init(&state->base, plane);
> +
> +     return &state->base;
>  }

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=41

Reply via email to