[FFmpeg-devel] [PATCH 1/5] avutil/hwcontext: Don't assume device_uninit is reentrant

Zhao Zhili quinkblack at foxmail.com
Tue Feb 20 14:08:54 EET 2024


device_uninit will be called by hwdevice_ctx_free. vulkan_device_uninit
is non-reentrant.
---
 libavutil/hwcontext.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c
index e23bad230f..e8c6256a73 100644
--- a/libavutil/hwcontext.c
+++ b/libavutil/hwcontext.c
@@ -205,18 +205,11 @@ fail:
 int av_hwdevice_ctx_init(AVBufferRef *ref)
 {
     AVHWDeviceContext *ctx = (AVHWDeviceContext*)ref->data;
-    int ret;
+    int ret = 0;
 
-    if (ctx->internal->hw_type->device_init) {
+    if (ctx->internal->hw_type->device_init)
         ret = ctx->internal->hw_type->device_init(ctx);
-        if (ret < 0)
-            goto fail;
-    }
 
-    return 0;
-fail:
-    if (ctx->internal->hw_type->device_uninit)
-        ctx->internal->hw_type->device_uninit(ctx);
     return ret;
 }
 
-- 
2.34.1



More information about the ffmpeg-devel mailing list