diff mbox series

[FFmpeg-devel,4/5] lavfi/dnn_backend_openvino.c: fix mem leak for RequestItem upon error

Message ID 20210313062855.27212-4-yejun.guo@intel.com
State Accepted
Commit df59ae8bb21b596125eccaab7d7984d03dd9ab45
Headers show
Series [FFmpeg-devel,1/5] lavfi/dnn_backend_openvino.c: fix mem leak for AVFrame upon error | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Guo, Yejun March 13, 2021, 6:28 a.m. UTC
---
 libavfilter/dnn/dnn_backend_openvino.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 50de6a996e..55cb0c757e 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -353,25 +353,23 @@  static DNNReturnType init_model_ov(OVModel *ov_model, const char *input_name, co
             goto err;
         }
 
+        item->callback.completeCallBackFunc = infer_completion_callback;
+        item->callback.args = item;
+        if (ff_safe_queue_push_back(ov_model->request_queue, item) < 0) {
+            av_freep(&item);
+            goto err;
+        }
+
         status = ie_exec_network_create_infer_request(ov_model->exe_network, &item->infer_request);
         if (status != OK) {
-            av_freep(&item);
             goto err;
         }
 
         item->tasks = av_malloc_array(ctx->options.batch_size, sizeof(*item->tasks));
         if (!item->tasks) {
-            av_freep(&item);
             goto err;
         }
         item->task_count = 0;
-
-        item->callback.completeCallBackFunc = infer_completion_callback;
-        item->callback.args = item;
-        if (ff_safe_queue_push_back(ov_model->request_queue, item) < 0) {
-            av_freep(&item);
-            goto err;
-        }
     }
 
     ov_model->task_queue = ff_queue_create();