[FFmpeg-devel] [PATCH 4/5] avutil/hwcontext_vulkan: Fix leaks in map_from_drm
Zhao Zhili
quinkblack at foxmail.com
Tue Feb 20 14:08:57 EET 2024
From: Zhao Zhili <zhilizhao at tencent.com>
Also simplify error handing.
---
This patch is untested since I don't have a proper device.
libavutil/hwcontext_vulkan.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
index c64094f31c..35a7d75cce 100644
--- a/libavutil/hwcontext_vulkan.c
+++ b/libavutil/hwcontext_vulkan.c
@@ -2633,7 +2633,8 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
if (ret != VK_SUCCESS) {
av_log(hwctx, AV_LOG_ERROR, "Failed to create semaphore: %s\n",
ff_vk_ret2str(ret));
- return AVERROR_EXTERNAL;
+ err = AVERROR_EXTERNAL;
+ goto fail;
}
/* We'd import a semaphore onto the one we created using
@@ -2752,14 +2753,7 @@ static int vulkan_map_from_drm_frame_desc(AVHWFramesContext *hwfc, AVVkFrame **f
return 0;
fail:
- for (int i = 0; i < desc->nb_layers; i++) {
- vk->DestroyImage(hwctx->act_dev, f->img[i], hwctx->alloc);
- vk->DestroySemaphore(hwctx->act_dev, f->sem[i], hwctx->alloc);
- }
- for (int i = 0; i < desc->nb_objects; i++)
- vk->FreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc);
-
- av_free(f);
+ vulkan_frame_free(hwfc, f);
return err;
}
--
2.34.1
More information about the ffmpeg-devel
mailing list