jpeg_v5_3_0_sw_init() returns directly when
amdgpu_jpeg_sysfs_reset_mask_init() fails, after the JPEG ring has been
initialized successfully. amdgpu_ring_init() allocated the ring buffer,
writeback slots and the vmid fence, and only amdgpu_ring_fini(), called
through amdgpu_jpeg_sw_fini(), releases them. Because the IP block's
status.sw is only set after sw_init() succeeds, the upper layers skip
sw_fini() for this block and the resources are leaked.
Unwind with amdgpu_jpeg_sw_fini(), as the other JPEG implementations do.
Fixes: 4aeaf3cbfa9f ("drm/amdgpu/jpeg: Add jpeg 5.3.0 support")
Cc: [email protected]
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/jpeg_v5_3_0.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_3_0.c
b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_3_0.c
index 8ddd12740a04..f2b049700989 100644
--- a/drivers/gpu/drm/amd/amdgpu/jpeg_v5_3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/jpeg_v5_3_0.c
@@ -109,8 +109,14 @@ static int jpeg_v5_3_0_sw_init(struct amdgpu_ip_block
*ip_block)
adev->jpeg.supported_reset |= AMDGPU_RESET_TYPE_PER_QUEUE;
r = amdgpu_jpeg_sysfs_reset_mask_init(adev);
if (r)
- return r;
+ goto err_jpeg;
+
return 0;
+
+err_jpeg:
+ amdgpu_jpeg_suspend(adev);
+ amdgpu_jpeg_sw_fini(adev);
+ return r;
}
/**
--
2.34.1