]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/panthor: Fix memory leak in panthor_ioctl_group_create()
authorJann Horn <jannh@google.com>
Wed, 13 Nov 2024 21:03:39 +0000 (22:03 +0100)
committerSteven Price <steven.price@arm.com>
Fri, 18 Jul 2025 15:48:00 +0000 (16:48 +0100)
When bailing out due to group_priority_permit() failure, the queue_args
need to be freed. Fix it by rearranging the function to use the
goto-on-error pattern, such that the success case flows straight without
indentation while error cases jump forward to cleanup.

Cc: stable@vger.kernel.org
Fixes: 5f7762042f8a ("drm/panthor: Restrict high priorities on group_create")
Signed-off-by: Jann Horn <jannh@google.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://lore.kernel.org/r/20241113-panthor-fix-gcq-bailout-v1-1-654307254d68@google.com
drivers/gpu/drm/panthor/panthor_drv.c

index 1116f2d2826eebc7461bddb42f241df21f03a0d8..0304eb83d0b2d725154bbc84bab00f7adea96868 100644 (file)
@@ -1103,14 +1103,15 @@ static int panthor_ioctl_group_create(struct drm_device *ddev, void *data,
 
        ret = group_priority_permit(file, args->priority);
        if (ret)
-               return ret;
+               goto out;
 
        ret = panthor_group_create(pfile, args, queue_args);
-       if (ret >= 0) {
-               args->group_handle = ret;
-               ret = 0;
-       }
+       if (ret < 0)
+               goto out;
+       args->group_handle = ret;
+       ret = 0;
 
+out:
        kvfree(queue_args);
        return ret;
 }