From patchwork Thu Mar 16 03:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ting Fu X-Patchwork-Id: 40694 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp3946117pzb; Wed, 15 Mar 2023 20:16:50 -0700 (PDT) X-Google-Smtp-Source: AK7set+nyVZ2xI4kxhuowCejVORazdZyepZ+LVdKtno1uAhEptitKeyyTM7U92+GVxzZ1Z6US8Ip X-Received: by 2002:a17:907:9882:b0:91f:5845:4e31 with SMTP id ja2-20020a170907988200b0091f58454e31mr9318356ejc.26.1678936610090; Wed, 15 Mar 2023 20:16:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678936610; cv=none; d=google.com; s=arc-20160816; b=uigofETAmhmYR93WAcPbxk6B5pUSA4J04/+lRBZFOGosYtEuuapUpcWuE5fhKqiIsr aOGDEamY88DGvnMhvmT3yWyufK45D/zpS9zJKfMHRUVD6R1x/3MUSHJt5R/rIptrGvDe gmivyyOYClud5p2N4WiOrMNf+kJpGhKJxmFYN7gSlBK482WVGsNM+d1foBYdXN9X5IIy niyfpqGeu8pMARcrbY8uyljct1NNL5N0Cscn43oU+2lsSCxocnrI658/s/RmH9Yu8tTs KT/qIQbGdVNGtiFVFuDT8UZO3DZqhL9qDLzbijZYNfgIpLpS8J55lvQa7caqE0XKAnaf W5zA== 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=72RBulgsL/eMcvuZ4dmbWkJGZvxH6LMkKOzXDY56ze8=; b=v3HFb3fCCMQER2eYOSvUtS9SyFUIAwXd8EcQjVGmgyzezsFjtEaZMi69Fz6ce5xmUd aeOdqtyyfLO2JsEDUMO5AcrrxG7cexkXALFFdvFaKZdIx4Vbkwf5zsKpfaSN4FLDiw4i V6sJpbBflbKt4mbaiUZjFMEil0SX0C+oGUNoHEBmyMsL9Udcml0TX+nV/gKE2h/5thBd MJ585QTBeVelGJVagntDm1l7GtKWmN7nEb7eP+vE2zi2iRCY0dDH+Tg5GUXXf8Ux2l37 dycg/2mCoFZIVr8o/McRMpxX7sDD3+OlP6e1Xua8X1w72q7FJOsrXTRHIUw+3gkPS5FR bEjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@intel.com header.s=Intel header.b=hzTw8ieP; 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 hf7-20020a1709072c4700b0092a85ac4204si7303920ejc.101.2023.03.15.20.16.49; Wed, 15 Mar 2023 20:16:50 -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=hzTw8ieP; 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 5F55A68BD94; Thu, 16 Mar 2023 05:16:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 61E2F68BD62 for ; Thu, 16 Mar 2023 05:16:37 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678936602; x=1710472602; h=from:to:subject:date:message-id:in-reply-to:references; bh=ExOJHXQk1VW8N08avHzcFFh5k8Ea3dxkHRBJPprdc/c=; b=hzTw8iePNJDuNq84eoda45ArRLSwAqBuUk9dMcWxu91uH+O91s7An2E6 rNMcktSnlab2CSk3iPTyxGW2JxxlX7h7e34rbQuFtOUg1UMXpmMoxMesL Eufi/KnkYfN47Mz1WBhTU915anwKesM4aF50a8nVYLMryL+m02HYaxpqC TvpIV9UP05WwPQC8kTUoZwGc03NdCf3JLyxAndPVq5MczhIQuslndwuM3 wrdJAhUH5K4+y7JqNmQvZnFsCg9VyRyYRm5GBM4yOypvtIbBJuEiJzazs e8+7ALhmaXdVsvKmCJcm4h90K2gH/dQnSdpZvTz2+s9jsVmQO429juhMu A==; X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="402747598" X-IronPort-AV: E=Sophos;i="5.98,264,1673942400"; d="scan'208";a="402747598" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Mar 2023 20:16:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10650"; a="712164937" X-IronPort-AV: E=Sophos;i="5.98,264,1673942400"; d="scan'208";a="712164937" Received: from semmer-ubuntu.sh.intel.com ([10.239.159.83]) by orsmga001.jf.intel.com with ESMTP; 15 Mar 2023 20:16:28 -0700 From: Ting Fu To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Mar 2023 11:00:15 +0800 Message-Id: <20230316030016.4096-2-ting.fu@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230316030016.4096-1-ting.fu@intel.com> References: <20230316030016.4096-1-ting.fu@intel.com> Subject: [FFmpeg-devel] [PATCH 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: atl48S/7515P 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 fb1a5f1350..5d809a8694 100644 --- a/libavfilter/dnn/dnn_backend_tf.c +++ b/libavfilter/dnn/dnn_backend_tf.c @@ -176,6 +176,7 @@ static int tf_start_inference(void *args) if (TF_GetCode(request->status) != TF_OK) { av_log(&tf_model->ctx, AV_LOG_ERROR, "%s", TF_Message(request->status)); tf_free_request(infer_request); + av_freep(&request); return DNN_GENERIC_ERROR; } return 0; @@ -466,6 +467,7 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename) { TF_DeleteGraph(tf_model->graph); tf_model->graph = NULL; + av_freep(&sess_config); av_log(ctx, AV_LOG_ERROR, "Failed to create new session with model graph\n"); return DNN_GENERIC_ERROR; } @@ -484,6 +486,7 @@ static int load_tf_model(TFModel *tf_model, const char *model_filename) tf_model->graph = NULL; TF_DeleteStatus(tf_model->status); tf_model->status = NULL; + av_freep(&sess_config); av_log(ctx, AV_LOG_ERROR, "Failed to run session when initializing\n"); return DNN_GENERIC_ERROR; } @@ -1177,12 +1180,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); }