On 11/26/26 12:11, Tvrtko Ursulin wrote:
> Use scoped cleanup for drm_syncobj_timeline_signal_ioctl points array
> allocation.
>
> This is a split out step towards converting the whole function with the
> goal of simpler error handling and easier extending with a fast path in
> the future.
>
> Signed-off-by: Tvrtko Ursulin <[email protected]>
> Cc: Christian König <[email protected]>
> Cc: Fei Yu <[email protected]>
> Cc: Maíra Canal <[email protected]>
> ---
> drivers/gpu/drm/drm_syncobj.c | 12 +++++-------
> 1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
> index 7d5c4e4e29b2..e05051c3895f 100644
> --- a/drivers/gpu/drm/drm_syncobj.c
> +++ b/drivers/gpu/drm/drm_syncobj.c
> @@ -1571,9 +1571,9 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device
> *dev, void *data,
> struct drm_file *file_private)
> {
> struct drm_syncobj_timeline_array *args = data;
> + u64 *points __free(kvfree) = NULL;
> struct drm_syncobj **syncobjs;
> struct dma_fence_chain **chains;
> - uint64_t *points;
> uint32_t i, j;
> int ret;
>
> @@ -1599,17 +1599,17 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device
> *dev, void *data,
> goto out;
> }
> if (!u64_to_user_ptr(args->points)) {
> - memset(points, 0, args->count_handles * sizeof(uint64_t));
> + memset(points, 0, args->count_handles * sizeof(u64));
> } else if (copy_from_user(points, u64_to_user_ptr(args->points),
> - sizeof(uint64_t) * args->count_handles)) {
> + sizeof(u64) * args->count_handles)) {
Yeah same comment as for the last patch, the approach of allocating points even
when it isn't used is rather questionable.
Regards,
Christian.
> ret = -EFAULT;
> - goto err_points;
> + goto out;
> }
>
> chains = kvmalloc_objs(*chains, args->count_handles);
> if (!chains) {
> ret = -ENOMEM;
> - goto err_points;
> + goto out;
> }
> for (i = 0; i < args->count_handles; i++) {
> chains[i] = dma_fence_chain_alloc();
> @@ -1630,8 +1630,6 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device
> *dev, void *data,
> }
> err_chains:
> kvfree(chains);
> -err_points:
> - kvfree(points);
> out:
> drm_syncobj_array_free(syncobjs, args->count_handles);
>