]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu/userqueue: Fix use after free in amdgpu_userq_buffer_vas_list_cleanup()
authorDan Carpenter <dan.carpenter@linaro.org>
Wed, 22 Oct 2025 11:03:24 +0000 (14:03 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Oct 2025 13:50:58 +0000 (09:50 -0400)
The amdgpu_userq_buffer_va_list_del() function frees "va_cursor" but it
is dereferenced on the next line when we print the debug message.  Print
the debug message first and then free it.

Fixes: 2a28f9665dca ("drm/amdgpu: track the userq bo va for its obj management")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c

index 9d4751a39c20d1242619f55e2ee824a8aeaca90e..2200e0bbf040abd9bdfeaceba6070e471f91799c 100644 (file)
@@ -159,9 +159,9 @@ static int amdgpu_userq_buffer_vas_list_cleanup(struct amdgpu_device *adev,
                        r = -EINVAL;
                        goto err;
                }
-               amdgpu_userq_buffer_va_list_del(mapping, va_cursor);
                dev_dbg(adev->dev, "delete the userq:%p va:%llx\n",
                        queue, va_cursor->gpu_addr);
+               amdgpu_userq_buffer_va_list_del(mapping, va_cursor);
        }
 err:
        amdgpu_bo_unreserve(queue->vm->root.bo);