From patchwork Fri Mar 24 07:30:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ting Fu X-Patchwork-Id: 40789 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp379112pzb; Fri, 24 Mar 2023 00:47:13 -0700 (PDT) X-Google-Smtp-Source: AKy350aAO111g3ZzTNdevlKRLJVHHCZ+oJLwOhRoI8XbVqXzpYyV7ucMaapopGCpjRoUKV2qMECZ X-Received: by 2002:a17:906:3c55:b0:925:a734:a012 with SMTP id i21-20020a1709063c5500b00925a734a012mr1686386ejg.12.1679644033055; Fri, 24 Mar 2023 00:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679644033; cv=none; d=google.com; s=arc-20160816; b=1D+Ia/G8Stv38jYEXltf6dsGQFzCPZEPtaziDsHMqmpkTPSUw4/0vKB3ys3uwiBOxk S251SE6zEurOVJLVV3KFfn4j3RlXFpRhGxj1yOryxYuLTNBK+l7MDHKun0Tt3UEQu+T+ acVIuS6RJnoma3yN7JIo4u+UMC9dwYJG2Bojk9FM5GIcybeURSCwyLXOFCoulhKG+k1f 26ZikNMq7e2yxXij/7jlu7z06RhoXVegGnvVeYPFNryn7/oK4G5nItynKCdyHbch0mB1 P9ReGDEm/IoRD9/es7+5MlX3qOnljQOfouVKCXLza4rLMee/KkE1XR3M1FQH+volJ1RC eQbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=DVQa4NpUhJQVsfErUWrRv1sU3IVyhdosRVo6tj4A5YY=; b=a45sLO4tjUW88TBM6JqXGHE/73ohwomVUFCtTUP2ncoGFcQq1r8bpD27ywZIyI2wG/ bzJNZrUVtgvkrtb/9mFUASvxNpua7vxI5bwSyW2+Ku250JJHCtsHoOQjU7BiNkfDyfcg 3eS1pgRfuIgDGYeqWdKafWYOz+IdQw09v9Zk0sKGmzL2mTxfHrcWvBwt7ve4UDO8Z9+0 iTiZmu+5+fFXnLOjN8DqxW0wOawqFNzAxqpVq1lGh4F0KqYUhMcgA/WcfETUGHxRYJbt m06e2OjEJWS7TE61UmhmPHRYM7SoQFIfWqTGabp0yPK8UjqaZf1DmAdyxL5p/wye4VLA yzug== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="ijSq/WI5"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i5-20020a17090639c500b0092f350cf846si15676074eje.760.2023.03.24.00.47.12; Fri, 24 Mar 2023 00:47:13 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b="ijSq/WI5"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 73D8768BF05; Fri, 24 Mar 2023 09:47:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E0DC568C56A for ; Fri, 24 Mar 2023 09:46:56 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1679644022; x=1711180022; h=from:to:subject:date:message-id:in-reply-to:references; bh=h2znzbhjBalh0UZ/L5+1QsTSDM6SUm7VsYCao5ufJhw=; b=ijSq/WI5zU3AiXMU3dhEZXPhBJMyGQmiW3M2B3FwWvG8p7YIkBfsYrQR s0/qVjsx6CjPLW/wfyz/ZlGMjDthwUs6lnpY9xBEYXxkCfaVMfT1WUJNB 1X/IgWYwGQvc36wPJp0id4opNOxOb0gmp7rBZJVnF8QVGaO7IeYHQP3B5 dCuapwm0p2z/pF5JoA0DzSOZuNrh7Mi/doT//YW7wapu4GKaBVqSVja6Z 0TX2p2CwOvX8C5EB0z+gFwhr03o/Zgcco/ljB1PEVECUIYcn0s6RmcC9H MrP6jrG2YEHR1TCH2iOBXHFzu8/0xciMVMMohfl4mxU93bzjauAt6ES1X A==; X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="320109985" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="320109985" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2023 00:46:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10658"; a="682590192" X-IronPort-AV: E=Sophos;i="5.98,287,1673942400"; d="scan'208";a="682590192" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.83]) by orsmga002.jf.intel.com with ESMTP; 24 Mar 2023 00:46:48 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Fri, 24 Mar 2023 15:30:39 +0800 Message-Id: <20230324073040.16310-2-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230324073040.16310-1-ting.fu@intel.com> References: <20230324073040.16310-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH V2 2/3] lavfi/dnn: fix mem leak in TF backend error handle X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: meXaylqVu7wY Signed-off-by: Ting Fu --- libavfilter/dnn/dnn_backend_tf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavfilter/dnn/dnn_backend_tf.c b/libavfilter/dnn/dnn_backend_tf.c index 9570f188d2..fe1baa2e5e 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -457,6 +457,7 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename) TF_DeleteSessionOptions(sess_opts); if (TF_GetCode(tf_model->status) != TF_OK) { + av_freep(&sess_config); av_log(ctx, AV_LOG_ERROR, "Failed to create new session with model graph\n"); return DNN_GENERIC_ERROR; } @@ -469,6 +470,7 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename) &init_op, 1, NULL, tf_model->status); if (TF_GetCode(tf_model->status) != TF_OK) { + av_freep(&sess_config); av_log(ctx, AV_LOG_ERROR, "Failed to run session when initializing\n"); return DNN_GENERIC_ERROR; } @@ -1125,6 +1127,7 @@ err: if (ff_safe_queue_push_back(tf_model->request_queue, request) < 0) { destroy_request_item(&request); } + ff_dnn_free_model_tf(&tf_model->model); return ret; } @@ -1161,12 +1164,14 @@ int ff_dnn_execute_model_tf(const DNNModel *model, DNNExecBaseParams *exec_param ret = extract_lltask_from_task(task, tf_model->lltask_queue); if (ret != 0) { + av_freep(&task); av_log(ctx, AV_LOG_ERROR, "unable to extract last level task from task.\n"); return ret; } request = ff_safe_queue_pop_front(tf_model->request_queue); if (!request) { + av_freep(&task); av_log(ctx, AV_LOG_ERROR, "unable to get infer request.\n"); return AVERROR(EINVAL); }