From: sashiko-bot@kernel.org
To: "Guangshuo Li" <liguangshuo@mail.sdu.edu.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/kmb: Fix potential invalid free of plane objects
Date: Wed, 18 Nov 2026 14:22:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-221194@kernel.org> (raw)
In-Reply-To: <20261118-324f82bd41-drm-kmb-0@mail.sdu.edu.cn>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/kmb: invalid CRTC and mode_config cleanup on kmb_probe()
error path [1]
--
commit ea7f217c42f68c4024aad8e879735018a1ecdb10
Author: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
drm/kmb: Fix potential invalid free of plane objects
This commit replaces drmm_kzalloc() and drmm_kfree() with kzalloc_obj()
and kfree() in kmb_plane_init() so plane allocations match the kfree() in
kmb_plane_destroy().
> diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
> index 1742c2c6dfd89..7c908ca23e5ba 100644
> --- a/drivers/gpu/drm/kmb/kmb_plane.c
> +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> @@ -581,7 +581,7 @@ struct kmb_plane *kmb_plane_init(struct drm_device *drm)
> BIT(DRM_MODE_BLEND_COVERAGE);
>
> for (i = 0; i < KMB_MAX_PLANES; i++) {
> - plane = drmm_kzalloc(drm, sizeof(*plane), GFP_KERNEL);
> + plane = kzalloc_obj(*plane);
>
> if (!plane) {
> drm_err(drm, "Failed to allocate plane\n");
> @@ -636,6 +636,6 @@ struct kmb_plane *kmb_plane_init(struct drm_device *drm)
>
> return primary;
> cleanup:
> - drmm_kfree(drm, plane);
> + kfree(plane);
> return ERR_PTR(ret);
> }
[Severity: High]
This problem wasn't introduced by this patch, but if kmb_plane_init() or
an earlier step in kmb_setup_mode_config() fails, doesn't the err_free
path in kmb_probe() still perform invalid CRTC and mode_config cleanup
[1]?
drivers/gpu/drm/kmb/kmb_drv.c:kmb_probe() {
...
ret = kmb_setup_mode_config(&kmb->drm);
if (ret)
goto err_free;
...
err_free:
drm_crtc_cleanup(&kmb->crtc);
drm_mode_config_cleanup(&kmb->drm);
...
}
When kmb_setup_mode_config() fails before drm_crtc_init_with_planes()
initializes kmb->crtc (for example when kmb_plane_init() returns an
error), drm_crtc_cleanup(&kmb->crtc) dereferences an uninitialized
crtc->head list entry, causing a NULL pointer dereference. In addition,
because kmb_setup_mode_config() uses drmm_mode_config_init(), calling
drm_mode_config_cleanup() explicitly at err_free causes it to run a second
time when devm_drm_dev_alloc() unwinds.
[1] https://sashiko.dev/#/bug/linux-d222f5e7-17ec-4c5d-8774-adf4a0718282
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118-324f82bd41-drm-kmb-0@mail.sdu.edu.cn?part=1
prev parent reply other threads:[~2026-11-18 14:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 14:15 [PATCH] drm/kmb: Fix potential invalid free of plane objects Guangshuo Li
2026-11-18 14:22 ` sashiko-bot [this message]
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=sashiko-outbox-221194@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=liguangshuo@mail.sdu.edu.cn \
--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