All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 6/7] drm/syncobj: Use scoped cleanup in drm_syncobj_array_find and callers
Date: Thu, 26 Nov 2026 11:19:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-235364@kernel.org> (raw)
In-Reply-To: <20261126111117.67342-7-tvrtko.ursulin@igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/syncobj: __free() variables not initialized at declaration
  site
--

commit d2db4e35813dabf4fb7e2f45ff5acb392b0b03ac
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>

drm/syncobj: Use scoped cleanup in drm_syncobj_array_find and callers

This commit converts drm_syncobj_array_find() and its ioctl callers to
use scoped cleanup (__free) and moves the syncobj array allocation and
maximum handle count checks into the callers.

> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index da90ae11382e3..6b4df322b12a8 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -1252,59 +1252,38 @@ static int drm_syncobj_array_wait(struct drm_device *dev,
>  	return 0;
>  }
>  
> -static int drm_syncobj_array_find(struct drm_file *file_private,
> -				  void __user *user_handles,
> -				  uint32_t count_handles,
> -				  struct drm_syncobj ***syncobjs_out)
> -{
> -	uint32_t i, *handles;
> +struct syncobj_array {
>  	struct drm_syncobj **syncobjs;
> -	int ret;
> +	unsigned int count;
> +};
>  
> -	if (count_handles > DRM_SYNCOBJ_MAX_HANDLES)
> -		return -EINVAL;
> +static void syncobj_array_free(struct syncobj_array *a)
> +{
> +	for (unsigned int i = 0; i < a->count; i++)
> +		drm_syncobj_put(a->syncobjs[i]);
> +}
>  
> -	handles = vmemdup_array_user(user_handles, count_handles,
> -				     sizeof(*handles));
> -	if (IS_ERR(handles))
> -		return PTR_ERR(handles);
> +DEFINE_FREE(syncobj_array, struct syncobj_array, syncobj_array_free(&_T))
>  
> -	syncobjs = kvmalloc_objs(*syncobjs, count_handles);
> -	if (syncobjs == NULL) {
> -		ret = -ENOMEM;
> -		goto err_free_handles;
> -	}
> +static int drm_syncobj_array_find(struct drm_file *file_private,
> +				  void __user *user_handles, unsigned int count,
> +				  struct syncobj_array *array)
> +{
> +	u32 *handles __free(kvfree) = NULL;
> +	unsigned int i;
>  
> -	for (i = 0; i < count_handles; i++) {
> -		syncobjs[i] = drm_syncobj_find(file_private, handles[i]);
> -		if (!syncobjs[i]) {
> -			ret = -ENOENT;
> -			goto err_put_syncobjs;
> -		}
> +	handles = vmemdup_array_user(user_handles, count, sizeof(*handles));

[ ... ]

> @@ -1312,10 +1291,11 @@ drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
>  		       struct drm_file *file_private)
>  {
>  	struct drm_syncobj_wait *args = data;
> -	struct drm_syncobj **syncobjs;
> +	struct drm_syncobj **syncobjs __free(kvfree) = NULL;
> +	struct syncobj_array array __free(syncobj_array) = {};
>  	unsigned int possible_flags;
>  	ktime_t t, *tp = NULL;
> -	int ret = 0;
> +	int ret;
>  
>  	if (!drm_core_check_feature(dev, DRIVER_SYNCOBJ))
>  		return -EOPNOTSUPP;
> @@ -1329,11 +1309,17 @@ drm_syncobj_wait_ioctl(struct drm_device *dev, void *data,
>  
>  	if (args->count_handles == 0)
>  		return 0;
> +	else if (args->count_handles > DRM_SYNCOBJ_MAX_HANDLES)
> +		return -EINVAL;
> +
> +	syncobjs = kvmalloc_objs(*syncobjs, args->count_handles);
> +	if (!syncobjs)
> +		return -ENOMEM;
>  
> +	array.syncobjs = syncobjs;

[Severity: Low]
This isn't a bug, but cleanup.h recommends defining and initializing
__free() variables in a single statement at their allocation site rather
than declaring them with = NULL at the top of the function and assigning
them later.  Doing that for handles in drm_syncobj_array_find() and for
syncobjs (and array) in drm_syncobj_wait_ioctl() and the other five
ioctl callers in this patch also ensures reverse-acquisition cleanup
order naturally without relying on manual declaration ordering at the
top of each function.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126111117.67342-1-tvrtko.ursulin@igalia.com?part=6

  reply	other threads:[~2026-11-26 11:20 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
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 [this message]
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-235364@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.