diff mbox series

[FFmpeg-devel,4/8] dnn_backend_openvino.c: refine code for error handle

Message ID 20201222074536.6306-1-yejun.guo@intel.com
State Accepted
Commit 38089925fa41d0b767e8c47fb236dec390ec38ac
Headers show
Series [FFmpeg-devel,1/8] vf_dnn_processing.c: replace filter_frame with activate func | 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 Dec. 22, 2020, 7:45 a.m. UTC
Signed-off-by: Xie, Lin <lin.xie@intel.com>
Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>
Signed-off-by: Guo, Yejun <yejun.guo@intel.com>
---
 libavfilter/dnn/dnn_backend_openvino.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c
index 1196db0c90..da6e640226 100644
--- a/libavfilter/dnn/dnn_backend_openvino.c
+++ b/libavfilter/dnn/dnn_backend_openvino.c
@@ -336,8 +336,11 @@  DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options,
     }
 
     ov_model = av_mallocz(sizeof(OVModel));
-    if (!ov_model)
-        goto err;
+    if (!ov_model) {
+        av_freep(&model);
+        return NULL;
+    }
+    model->model = (void *)ov_model;
     ov_model->model = model;
     ov_model->ctx.class = &dnn_openvino_class;
     ctx = &ov_model->ctx;
@@ -377,7 +380,6 @@  DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options,
     if (status != OK)
         goto err;
 
-    model->model = (void *)ov_model;
     model->get_input = &get_input_ov;
     model->get_output = &get_output_ov;
     model->options = options;
@@ -386,19 +388,7 @@  DNNModel *ff_dnn_load_model_ov(const char *model_filename, const char *options,
     return model;
 
 err:
-    if (model)
-        av_freep(&model);
-    if (ov_model) {
-        if (ov_model->infer_request)
-            ie_infer_request_free(&ov_model->infer_request);
-        if (ov_model->exe_network)
-            ie_exec_network_free(&ov_model->exe_network);
-        if (ov_model->network)
-            ie_network_free(&ov_model->network);
-        if (ov_model->core)
-            ie_core_free(&ov_model->core);
-        av_freep(&ov_model);
-    }
+    ff_dnn_free_model_ov(&model);
     return NULL;
 }