From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id ED6D8467FB for ; Mon, 19 Jun 2023 06:19:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E437F68BF89; Mon, 19 Jun 2023 09:19:33 +0300 (EEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BEFC468BDDE for ; Mon, 19 Jun 2023 09:19:26 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1687155571; x=1718691571; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=13RhCQYd88z16FYBu6gavqUP0t3KaHeRWcBUbwvy2jA=; b=FXE/fsMklx7XtBl6MrtVgJ6iqBuPhnXl3iha+zCGUQ8cJrV3y5eAbxnP Im6s7l2UxwsUfnGUSARzSUlaizwzKfTkxcLRYU1IZ8TIbwQzv+9Z+CdFp CwawIu09eBQ7XZ7s79EDlLWpcwvRCf2muIHGvjlSwbeU+bdFPkrm0R/dG ESbYxW+ALAvkTVLQEmRpBZuRDSYhj1i0EaGD1JU3tl3STCRk54bx0QfcF qp9oaNtH2igBtEPTAoAaxkl1qOpOC7/n3OK3z6vjuPNMTkzfz3Y97IDPz VXE82Y38orFX6HgJ6/LtqRG1VV7KEuuCohh91LHwIP4Sx34KRpqnc8SkF w==; X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="362089623" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="362089623" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jun 2023 23:19:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10745"; a="858099902" X-IronPort-AV: E=Sophos;i="6.00,254,1681196400"; d="scan'208";a="858099902" Received: from desktop-qn7n0nf.sh.intel.com (HELO localhost.localdomain) ([10.239.160.59]) by fmsmga001.fm.intel.com with ESMTP; 18 Jun 2023 23:19:22 -0700 From: Tong Wu To: ffmpeg-devel@ffmpeg.org Date: Mon, 19 Jun 2023 14:15:07 +0800 Message-ID: <20230619061509.1363-1-tong1.wu@intel.com> X-Mailer: git-send-email 2.41.0.windows.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/3] avutil/hwcontext_qsv: register free function for device_derive 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 Cc: Tong Wu , Wenbin Chen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: When qsv device is created by device_derive, the ctx->free function is not registered, causing potential memory leak because of not properly closing the MFX session. Signed-off-by: Tong Wu Signed-off-by: Wenbin Chen --- libavutil/hwcontext_qsv.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 4ed4242ddf..878ecd886e 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -2094,6 +2094,15 @@ static int qsv_device_derive(AVHWDeviceContext *ctx, AVDictionary *opts, int flags) { mfxIMPL impl; + QSVDevicePriv *priv; + + priv = av_mallocz(sizeof(*priv)); + if (!priv) + return AVERROR(ENOMEM); + + ctx->user_opaque = priv; + ctx->free = qsv_device_free; + impl = choose_implementation("hw_any", child_device_ctx->type); return qsv_device_derive_from_child(ctx, impl, child_device_ctx, flags); -- 2.41.0.windows.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".