Previously if we entered an error path between these two points, we
could leak the relocs tables due to submit->nr_cmds still being zero.
In practice, relocs are disallowed on a6xx+, and non-ancient userspace
will not use relocs on earlier gens unless running on an ancient kernel.
But userspace could use this to trigger a memory leak.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Signed-off-by: Rob Clark <robin.clark@oss.qualcomm.com>
Patchwork: https://patchwork.freedesktop.org/patch/743085/
Message-ID: <
20260729155609.20190-6-robin.clark@oss.qualcomm.com>
ret = -ENOMEM;
goto out;
}
+
+ submit->nr_cmds = i + 1;
+
ret = copy_from_user(submit->cmd[i].relocs, userptr, sz);
if (ret) {
ret = -EFAULT;
goto out;
}
- submit->nr_cmds = args->nr_cmds;
-
idr_preload(GFP_KERNEL);
spin_lock(&queue->idr_lock);