From patchwork Sat Mar 13 06:28:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Guo, Yejun" X-Patchwork-Id: 26375 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 87B8544B263 for ; Sat, 13 Mar 2021 08:40:09 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 657E968AC21; Sat, 13 Mar 2021 08:40:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 94B1168AC04 for ; Sat, 13 Mar 2021 08:40:02 +0200 (EET) IronPort-SDR: ozf5UfBeqVZnL7ac0YNPS0yRbxFEeIvAiBhHYb/62htU6k7VKMeCH3YhNJFMPcMGHvXqmLOyUx RLFWINez6x1w== X-IronPort-AV: E=McAfee;i="6000,8403,9921"; a="168195468" X-IronPort-AV: E=Sophos;i="5.81,245,1610438400"; d="scan'208";a="168195468" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2021 22:39:52 -0800 IronPort-SDR: RFN8MN5T5qYsxEwNE/+2YqV9yYICo0uymqKSM1QDvulZp9LFEpKoi83LrGzDTeKS6uicbcuvXF DiiLa+dC5vVA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,245,1610438400"; d="scan'208";a="604197273" Received: from yguo18-skl-u1604.sh.intel.com ([10.239.159.53]) by fmsmga005.fm.intel.com with ESMTP; 12 Mar 2021 22:39:51 -0800 From: "Guo, Yejun" To: ffmpeg-devel@ffmpeg.org Date: Sat, 13 Mar 2021 14:28:51 +0800 Message-Id: <20210313062855.27212-1-yejun.guo@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH 1/5] lavfi/dnn_backend_openvino.c: fix mem leak for AVFrame upon error 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" --- libavfilter/dnn/dnn_backend_openvino.c | 30 ++++++++++++++------------ 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/libavfilter/dnn/dnn_backend_openvino.c b/libavfilter/dnn/dnn_backend_openvino.c index 5be053b7f8..d86fb124d5 100644 --- a/libavfilter/dnn/dnn_backend_openvino.c +++ b/libavfilter/dnn/dnn_backend_openvino.c @@ -485,25 +485,12 @@ static DNNReturnType get_output_ov(void *model, const char *input_name, int inpu OVContext *ctx = &ov_model->ctx; TaskItem task; RequestItem request; - AVFrame *in_frame = av_frame_alloc(); + AVFrame *in_frame = NULL; AVFrame *out_frame = NULL; TaskItem *ptask = &task; IEStatusCode status; input_shapes_t input_shapes; - if (!in_frame) { - av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for input frame\n"); - return DNN_ERROR; - } - out_frame = av_frame_alloc(); - if (!out_frame) { - av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for output frame\n"); - av_frame_free(&in_frame); - return DNN_ERROR; - } - in_frame->width = input_width; - in_frame->height = input_height; - if (ctx->options.input_resizable) { status = ie_network_get_input_shapes(ov_model->network, &input_shapes); input_shapes.shapes->shape.dims[2] = input_height; @@ -523,6 +510,21 @@ static DNNReturnType get_output_ov(void *model, const char *input_name, int inpu } } + in_frame = av_frame_alloc(); + if (!in_frame) { + av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for input frame\n"); + return DNN_ERROR; + } + in_frame->width = input_width; + in_frame->height = input_height; + + out_frame = av_frame_alloc(); + if (!out_frame) { + av_log(ctx, AV_LOG_ERROR, "Failed to allocate memory for output frame\n"); + av_frame_free(&in_frame); + return DNN_ERROR; + } + task.done = 0; task.do_ioproc = 0; task.async = 0;