From patchwork Tue Dec 22 07:45:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 24616 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7B49044A63F for ; Tue, 22 Dec 2020 09:46:46 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5779C68A98A; Tue, 22 Dec 2020 09:46:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A16C680181 for ; Tue, 22 Dec 2020 09:46:38 +0200 (EET) IronPort-SDR: caxPzIp7fJgJYf08T6R7mg67zLeftT2tzpZFWQObP9gR4SuEbT4xiRwhuZor/o+/bpFHs5/IDA TMGGnsjmznsg== X-IronPort-AV: E=McAfee;i="6000,8403,9842"; a="237396326" X-IronPort-AV: E=Sophos;i="5.78,438,1599548400"; d="scan'208";a="237396326" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Dec 2020 23:46:37 -0800 IronPort-SDR: zdqz2CensD2WblPUIpU67p2ELU/52Tua7WslDC1v1nE53ljW+BdEwIE3QmYuU/mUv6B3/RjIeA 9rEio6uGQPKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.78,438,1599548400"; d="scan'208";a="564202267" Received: from yguo18-skl-u1604.sh.intel.com (HELO localhost.localdomain) ([10.239.159.53]) by fmsmga005.fm.intel.com with ESMTP; 21 Dec 2020 23:46:36 -0800 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Tue, 22 Dec 2020 15:45:36 +0800 Message-Id: <20201222074536.6306-1-yejun.guo@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 4/8] dnn_backend_openvino.c: refine code for error handle X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: yejun.guo@intel.com MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Xie, Lin Signed-off-by: Wu Zhiwen Signed-off-by: Guo, Yejun --- libavfilter/dnn/dnn_backend_openvino.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) 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; }