Skip to contentSkip to conversation

drm/amdgpu: Fix memory leak in amdgpu_fence_emit

PATCH In review Navid Emamdoost 2 participants 2 messages Oct 21, 2019 – Oct 22, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Fix memory leak in amdgpu_fence_emit

In the impelementation of amdgpu_fence_emit() if dma_fence_wait() fails and returns an errno, before returning the allocated memory for fence should be released.

Fixes 3d2aca8c8620 ("drm/amdgpu: fix old fence check in amdgpu_fence_emit")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +3 -1
index 23085b352cf2..2f59c9270a7e 100644
@@ -166,8 +166,10 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f,
 		if (old) {
 			r = dma_fence_wait(old, false);
 			dma_fence_put(old);
-			if (r)
+			if (r) {
+				dma_fence_put(fence);
 				return r;
+			}
 		}
 	}
 
Signature · 1 line
2.17.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 21.10.19 um 20:09 schrieb Navid Emamdoost:

Quoted 6 lines

In the impelementation of amdgpu_fence_emit() if dma_fence_wait() fails and returns an errno, before returning the allocated memory for fence should be released.

Fixes 3d2aca8c8620 ("drm/amdgpu: fix old fence check in amdgpu_fence_emit")
Quoted 20 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +3 -1
index 23085b352cf2..2f59c9270a7e 100644
@@ -166,8 +166,10 @@ int amdgpu_fence_emit(struct amdgpu_ring *ring, struct dma_fence **f,
  		if (old) {
  			r = dma_fence_wait(old, false);
  			dma_fence_put(old);
-			if (r)
+			if (r) {
+				dma_fence_put(fence);
  				return r;
+			}
  		}
  	}