diff options
| author | Dan Carpenter <[email protected]> | 2025-04-12 14:39:32 +0000 |
|---|---|---|
| committer | Alex Deucher <[email protected]> | 2025-04-21 14:52:53 +0000 |
| commit | 8ff7c78baeeab746432934f7de82d56706c00c50 (patch) | |
| tree | 4cf732f2763ba778072acb40099d07ca7c83aa65 /drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | |
| parent | drm/amdgpu/userq: move runpm handling into core userq code (diff) | |
| download | kernel-8ff7c78baeeab746432934f7de82d56706c00c50.tar.gz kernel-8ff7c78baeeab746432934f7de82d56706c00c50.zip | |
drm/amdgpu: Fix double free in amdgpu_userq_fence_driver_alloc()
The goto frees "fence_drv" so this is a double free bug. There is no
need to call amdgpu_seq64_free(adev, fence_drv->va) since the seq64
allocation failed so change the goto to goto free_fence_drv. Also
propagate the error code from amdgpu_seq64_alloc() instead of hard coding
it to -ENOMEM.
Fixes: e7cf21fbb277 ("drm/amdgpu: Few optimization and fixes for userq fence driver")
Reviewed-by: Arvind Yadav <[email protected]>
Signed-off-by: Dan Carpenter <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c')
| -rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c index ee73d7846c2c..e2e0bd6ae807 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c @@ -84,11 +84,8 @@ int amdgpu_userq_fence_driver_alloc(struct amdgpu_device *adev, /* Acquire seq64 memory */ r = amdgpu_seq64_alloc(adev, &fence_drv->va, &fence_drv->gpu_addr, &fence_drv->cpu_addr); - if (r) { - kfree(fence_drv); - r = -ENOMEM; - goto free_seq64; - } + if (r) + goto free_fence_drv; memset(fence_drv->cpu_addr, 0, sizeof(u64)); |
