Use scoped cleanup for drm_syncobj_array_wait_timeout 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 | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 663d6cb8dbf8..bd3f9e74e678 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -193,6 +193,7 @@
*/
#include <linux/anon_inodes.h>
+#include <linux/cleanup.h>
#include <linux/dma-fence-unwrap.h>
#include <linux/eventfd.h>
#include <linux/export.h>
@@ -1052,8 +1053,8 @@ static signed long drm_syncobj_array_wait_timeout(struct
drm_syncobj **syncobjs,
ktime_t *deadline)
{
struct syncobj_wait_entry *entries;
+ u64 *points __free(kvfree) = NULL;
struct dma_fence *fence;
- uint64_t *points;
uint32_t signaled_count, i;
if (flags & (DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT |
@@ -1063,23 +1064,18 @@ static signed long
drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
}
points = kvmalloc_objs(*points, count);
- if (points == NULL)
+ if (!points)
return -ENOMEM;
- if (!user_points) {
- memset(points, 0, count * sizeof(uint64_t));
-
- } else if (copy_from_user(points, user_points,
- sizeof(uint64_t) * count)) {
- timeout = -EFAULT;
- goto err_free_points;
- }
+ if (!user_points)
+ memset(points, 0, count * sizeof(u64));
+ else if (copy_from_user(points, user_points, sizeof(u64) * count))
+ return -EFAULT;