]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/xe/oa: Fix sync entry leak on OA config emit failure
authorLinmao Li <lilinmao@kylinos.cn>
Fri, 31 Jul 2026 01:19:32 +0000 (09:19 +0800)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Thu, 13 Aug 2026 12:56:33 +0000 (14:56 +0200)
xe_oa_emit_oa_config() releases the sync entries and the syncs array
only on its success path. When it fails before the point of no return
(fence allocation, config buffer allocation or batch submission), it
returns without touching stream->syncs.

The stream open path handles such failures in the caller, but
xe_oa_config_locked() propagates the error without any cleanup, so the
syncs array and the fence references held by the parsed entries are
leaked. The next config ioctl overwrites stream->syncs, making the
memory unreachable for good.

Clean up the parsed syncs when xe_oa_emit_oa_config() fails, matching
the cleanup done by the stream open error path.

Fixes: 9920c8b88c5c ("drm/xe/oa: Add syncs support to OA config ioctl")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Link: https://patch.msgid.link/20260731011932.3426219-1-lilinmao@kylinos.cn
(cherry picked from commit 8af97b3da2cfce04e6b457c6eb17ed3c1daf912b)
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
drivers/gpu/drm/xe/xe_oa.c

index 2dce6a47202ca6328d02379e5c90c61691fde787..9cf962b71cb6593c7050c3df510ec9a030eabfc6 100644 (file)
@@ -1594,6 +1594,10 @@ static long xe_oa_config_locked(struct xe_oa_stream *stream, u64 arg)
                config = xchg(&stream->oa_config, config);
                drm_dbg(&stream->oa->xe->drm, "changed to oa config uuid=%s\n",
                        stream->oa_config->uuid);
+       } else {
+               while (param.num_syncs--)
+                       xe_sync_entry_cleanup(&param.syncs[param.num_syncs]);
+               kfree(param.syncs);
        }
 
 err_config_put: