drm/amdgpu: fix memory leak
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix memory leak
cleanup error handling code and make sure temporary info array with the handles are freed by amdgpu_bo_list_put() on idr_replace()'s failure.
Signed-off-by Nirmoy Das <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +7 -7
@@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r =amdgpu_bo_create_list_entry_array (&args->in, &info);if (r) - goto error_free; +return r;switch (args->in.operation) {case AMDGPU_BO_LIST_OP_CREATE :
@@ -283,8 +283,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL );mutex_unlock (&fpriv->bo_list_lock);if (r <0 ) { -amdgpu_bo_list_put (list); -return r; + goto error_put_list; } handle = r;
@@ -306,9 +305,8 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,mutex_unlock (&fpriv->bo_list_lock);if (IS_ERR (old)) { -amdgpu_bo_list_put (list); r =PTR_ERR (old); - goto error_free; + goto error_put_list; }amdgpu_bo_list_put (old);
@@ -325,8 +323,10 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,return 0 ; +error_put_list: +amdgpu_bo_list_put (list); + error_free: -if (info) -kvfree (info); +kvfree (info);return r; }
Signature · 6 lines
2.23.0 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Koenig, Christian
Reviewed-by Christian KönigAm 04.10.19 um 15:51 schrieb Nirmoy Das:
Quoted 5 lines
cleanup error handling code and make sure temporary info array with the handles are freed by
amdgpu_bo_list_put()on idr_replace()'s failure.Signed-off-by Nirmoy Das <[email protected]>
Reviewed-by Christian König <[email protected]>
Quoted 41 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +3
-5@@ -270,7 +270,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r =amdgpu_bo_create_list_entry_array (&args->in, &info);if (r) - goto error_free; +return r;switch (args->in.operation) {case AMDGPU_BO_LIST_OP_CREATE :@@ -283,8 +283,7 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, r =idr_alloc (&fpriv->bo_list_handles, list,1 ,0 ,GFP_KERNEL );mutex_unlock (&fpriv->bo_list_lock);if (r <0 ) { -amdgpu_bo_list_put (list); -return r; + goto error_put_list; } handle = r;@@ -306,9 +305,8 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,mutex_unlock (&fpriv->bo_list_lock);if (IS_ERR (old)) { -amdgpu_bo_list_put (list); r =PTR_ERR (old); - goto error_free; + goto error_put_list; }amdgpu_bo_list_put (old);@@ -325,8 +323,10 @@ int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data,return 0 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c int amdgpu_bo_list_ioctl(struct drm_device *dev, void *data, · line 332
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bo_list.c +4
-2+error_put_list: +amdgpu_bo_list_put (list); + error_free: -if (info) -kvfree (info); +kvfree (info);return r; }
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx