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 <[email protected]> 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/[email protected]?part=5
