dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 08/40] drm/kmb: Convert to atomic_create_state
Date: Mon, 31 Aug 2026 19:44:15 +0000	[thread overview]
Message-ID: <20260831194416.229931F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831-drm-no-more-plane-reset-v3-8-1877c7aa57b3@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but calling kfree() on an interior pointer allocated by drmm_kzalloc() causes heap corruption and a double free during DRM device teardown.
--

commit 8cb00e04f7c7c0f7305c33451c9eebfc86df5dd2
Author: Maxime Ripard <mripard@kernel.org>

drm/kmb: Convert to atomic_create_state

The plane only initializes a pristine state in its reset hook
using drm_atomic_helper_plane_reset(), which is equivalent to what
atomic_create_state expects. Convert to it.

[ ... ]

> diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
> index a0001edb1e21a..1742c2c6dfd89 100644
> --- a/drivers/gpu/drm/kmb/kmb_plane.c
> +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> @@ -561,7 +561,7 @@ static const struct drm_plane_funcs kmb_plane_funcs = {
>  	.update_plane = drm_atomic_helper_update_plane,
>  	.disable_plane = drm_atomic_helper_disable_plane,
>  	.destroy = kmb_plane_destroy,

[Severity: High]
This isn't a bug introduced by this patch, but calling kfree() on an
interior pointer allocated by drmm_kzalloc() causes heap corruption and a
double free during DRM device teardown.

Looking at kmb_plane_init(), the plane is allocated using the DRM-managed
allocator:

drivers/gpu/drm/kmb/kmb_plane.c:kmb_plane_init() {
        ...
        plane = drmm_kzalloc(drm, sizeof(*plane), GFP_KERNEL);
        ...
}

However, in kmb_plane_destroy(), an unmanaged kfree() is erroneously called:

drivers/gpu/drm/kmb/kmb_plane.c:kmb_plane_destroy() {
        ...
        kfree(kmb_plane);
        ...
}

Since this is reachable during normal device teardown or initialization
failure, will this trigger a kernel panic due to an invalid free followed
by a double free when the DRM managed resource is cleaned up by
drm_dev_put()?

> -	.reset = drm_atomic_helper_plane_reset,
> +	.atomic_create_state = drm_atomic_helper_plane_create_state,
>  	.atomic_duplicate_state = drm_atomic_helper_plane_duplicate_state,
>  	.atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
>  };

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-drm-no-more-plane-reset-v3-0-1877c7aa57b3@kernel.org?part=8

  reply	other threads:[~2026-08-31 19:44 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 16:17 [PATCH v3 00/40] drm/plane: Convert all drivers to atomic_create_state and remove reset Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 01/40] drm/simple-kms: Remove unused reset_plane hook Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 02/40] drm/vkms: Convert to atomic_create_state Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 03/40] drm/gem-atomic-helper: Remove __drm_gem_reset_shadow_plane() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 04/40] drm/amdgpu: Convert to atomic_create_state Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 05/40] drm/fsl-dcu: " Maxime Ripard
2026-08-31 19:22   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 06/40] drm/hisilicon/kirin: " Maxime Ripard
2026-08-31 18:07   ` John Stultz
2026-08-31 19:31   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 07/40] drm/imx/dc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 08/40] drm/kmb: " Maxime Ripard
2026-08-31 19:44   ` sashiko-bot [this message]
2026-08-31 16:17 ` [PATCH v3 09/40] drm/logicvc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 10/40] drm/loongson: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 11/40] drm/lcdif: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 12/40] drm/mxsfb: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 13/40] drm/qxl: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 14/40] drm/rockchip: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 15/40] drm/sprd: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 16/40] drm/sti: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 17/40] drm/stm: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 18/40] drm/tests: kunit: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 19/40] drm/tilcdc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 20/40] drm/vboxvideo: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 21/40] drm/verisilicon: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 22/40] drm/virtio: " Maxime Ripard
2026-08-31 21:16   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 23/40] drm/xlnx: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 24/40] drm/atomic-state-helper: Remove drm_atomic_helper_plane_reset() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 25/40] drm/amdgpu_dm: Convert to atomic_create_state Maxime Ripard
2026-08-31 21:37   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 26/40] drm/armada: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 27/40] drm/atmel-hlcdc: Drop spurious csc_init call from reset Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 28/40] drm/atmel-hlcdc: Convert to atomic_create_state Maxime Ripard
2026-08-31 21:56   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 29/40] drm/exynos: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 30/40] drm/imx/ipuv3: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 31/40] drm/mediatek: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 32/40] drm/nouveau: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 33/40] drm/omap: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 34/40] drm/rcar-du: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 35/40] drm/rz-du: " Maxime Ripard
2026-08-31 22:39   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 36/40] drm/shmobile: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 37/40] drm/sun4i: layer: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 38/40] drm/vmwgfx: " Maxime Ripard
2026-08-31 17:47   ` Zack Rusin
2026-08-31 22:58   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 39/40] drm/atomic-state-helper: Remove __drm_atomic_helper_plane_reset() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 40/40] drm/plane: Remove reset Maxime Ripard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260831194416.229931F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox