From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/7] drm/syncobj: Use scoped cleanup for drm_syncobj_timeline_signal_ioctl chains
Date: Thu, 26 Nov 2026 11:21:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-235367@kernel.org> (raw)
In-Reply-To: <20261126111117.67342-6-tvrtko.ursulin@igalia.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/syncobj: mixed goto and __free() in
drm_syncobj_timeline_signal_ioctl()
--
commit 97e96ebc6a98c85d2c6da0c4d034fb53f985a940
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
drm/syncobj: Use scoped cleanup for drm_syncobj_timeline_signal_ioctl chains
This commit introduces a syncobj_chains helper struct with DEFINE_FREE()
to manage the dma_fence_chain array in drm_syncobj_timeline_signal_ioctl()
using __free(syncobj_chains).
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index e05051c3895fe..da90ae11382e3 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -1566,15 +1566,33 @@ drm_syncobj_signal_ioctl(struct drm_device *dev, void *data,
> return ret;
> }
>
> +struct syncobj_chains {
> + struct dma_fence_chain **chains;
> + unsigned int count;
> +};
> +
> +static void syncobj_chains_free(struct syncobj_chains *c)
> +{
> + if (!c->chains)
> + return;
> +
> + for (unsigned int i = 0; i < c->count; i++)
> + dma_fence_chain_free(c->chains[i]);
> +
> + kvfree(c->chains);
> +}
> +
> +DEFINE_FREE(syncobj_chains, struct syncobj_chains, syncobj_chains_free(&_T))
> +
> int
> drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
> struct drm_file *file_private)
> {
> struct drm_syncobj_timeline_array *args = data;
> + struct syncobj_chains chains __free(syncobj_chains) = {};
> u64 *points __free(kvfree) = NULL;
> struct drm_syncobj **syncobjs;
> - struct dma_fence_chain **chains;
> - uint32_t i, j;
> + unsigned int i;
> int ret;
>
> if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ_TIMELINE))
> @@ -1606,30 +1624,29 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
> goto out;
> }
>
> - chains = kvmalloc_objs(*chains, args->count_handles);
> - if (!chains) {
> + chains.chains = kvmalloc_objs(*chains.chains, args->count_handles);
> + if (!chains.chains) {
> ret = -ENOMEM;
> goto out;
> }
> for (i = 0; i < args->count_handles; i++) {
> - chains[i] = dma_fence_chain_alloc();
> - if (!chains[i]) {
> - for (j = 0; j < i; j++)
> - dma_fence_chain_free(chains[j]);
> + chains.chains[i] = dma_fence_chain_alloc();
> + if (!chains.chains[i]) {
> ret = -ENOMEM;
> - goto err_chains;
> + goto out;
> }
> + chains.count++;
> }
>
> for (i = 0; i < args->count_handles; i++) {
> struct dma_fence *fence = dma_fence_get_stub();
>
> - drm_syncobj_add_point(syncobjs[i], chains[i],
> + drm_syncobj_add_point(syncobjs[i], chains.chains[i],
> fence, points[i]);
> + chains.chains[i] = NULL; /* Ownership transferred to syncobj */
> dma_fence_put(fence);
> }
> -err_chains:
> - kvfree(chains);
> +
> out:
> drm_syncobj_array_free(syncobjs, args->count_handles);
[Severity: Low]
This isn't a bug, but drm_syncobj_timeline_signal_ioctl() mixes __free()
cleanup with goto out unwinding for syncobjs, and declares chains empty
at the top of the function (before points) instead of defining and
initializing it where the array is allocated. Follow-up commit
"drm/syncobj: Use scoped cleanup in drm_syncobj_array_find and callers"
removes the goto label, though both it and commit "drm/syncobj: Add
temporary array allocation fast paths" still declare chains at the top of
the function before points, which reverses the LIFO cleanup order
relative to the allocation order.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126111117.67342-1-tvrtko.ursulin@igalia.com?part=5
next prev parent reply other threads:[~2026-11-26 11:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 11:11 [PATCH 0/7] DRM syncobj scoped cleanup and fast path Tvrtko Ursulin
2026-11-26 11:11 ` [PATCH 1/7] drm/syncobj: Use vmemdup_array_user in drm_syncobj_array_find Tvrtko Ursulin
2026-11-26 11:59 ` Christian König
2026-11-26 11:11 ` [PATCH 2/7] drm/syncobj: Use scoped cleanup for drm_syncobj_array_wait_timeout points Tvrtko Ursulin
2026-11-26 12:09 ` Christian König
2026-11-26 14:22 ` Tvrtko Ursulin
2026-11-26 11:11 ` [PATCH 3/7] drm/syncobj: Use scoped cleanup for drm_syncobj_array_wait_timeout syncobjs Tvrtko Ursulin
2026-11-26 11:17 ` sashiko-bot
2026-11-26 12:11 ` Christian König
2026-11-26 14:33 ` Tvrtko Ursulin
2026-11-26 11:11 ` [PATCH 4/7] drm/syncobj: Use scoped cleanup for drm_syncobj_timeline_signal_ioctl points Tvrtko Ursulin
2026-11-26 12:15 ` Christian König
2026-11-26 11:11 ` [PATCH 5/7] drm/syncobj: Use scoped cleanup for drm_syncobj_timeline_signal_ioctl chains Tvrtko Ursulin
2026-11-26 11:21 ` sashiko-bot [this message]
2026-11-26 12:19 ` Christian König
2026-11-26 11:11 ` [PATCH 6/7] drm/syncobj: Use scoped cleanup in drm_syncobj_array_find and callers Tvrtko Ursulin
2026-11-26 11:19 ` sashiko-bot
2026-11-26 11:11 ` [PATCH 7/7] drm/syncobj: Add temporary array allocation fast paths Tvrtko Ursulin
2026-11-26 11:22 ` sashiko-bot
2026-11-26 11:49 ` [PATCH v2 " Tvrtko Ursulin
2026-11-27 7:59 ` Fei Yu
2026-11-27 7:58 ` [PATCH 0/7] DRM syncobj scoped cleanup and fast path Fei Yu
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-235367@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tvrtko.ursulin@igalia.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.