From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 7DC31460F4 for ; Tue, 16 Sep 2025 08:24:42 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'fRC3pSSH1sbkVQ0RGNoYRW/gTd4CC0N/gimY5w50gh0=', expected b'I4c3lKClvdN8PMzNwpIZRMK53wT9Y24TAjyKGXjBFTI=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1758011053; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=fRC3pSSH1sbkVQ0RGNoYRW/gTd4CC0N/gimY5w50gh0=; b=KAK6lD+xu2N9qKZXulklhK9mw39yp20xKMB5vaPoDi/5JqEGCIswt868fv7X6SnZGl5T2 oolTqBf6MkvPJ+QM3E2TrsTFcGEDuAeqTSgEYVFfxw3CMnC0WgTKKHdYWsxzMWW/a4DFiY7 OqcUWoqsF2qMKwep6hT9alfV2wzvJZVrhjOirVAaY8ENYEPEgSBEld6D0SfGX7z40qCvaMj TEPm0zAPpLaqm9OS708L8ATWrut3qmEwV9PbkYkQLAKAVWGWmah04lfbgoccDBJViRbtZVP lkiorYdqNutgSznO5IgzUwV3aGa8xCMkA7dF5zP1LuDY0SIiZew4ymfDTb6w== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 8601068E8B6; Tue, 16 Sep 2025 11:24:13 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1758011050; b=GU+sC1/YQV1GRsDS8YgHtYeALsZnBDzq0AsFMu1ewQyxlkJI/fSKo6+UIldyZysAhqxDo XAX4JNaRWxscQBzm8Z6YOv/XEXLCMTYeyoOnZ+P2um26CwLYdxIJx32NCWLPkgaZXD+f4UY eTMTNSc48NxqKkS7fgAIN23DIiIdrzOEZbjggKHz4Ryx0rwn2v2eCpic6c6LiZm2p+qWTW3 5bp90VqwYfWx6WsfOuIAGNfnApP50H+7OP3gXa9FPKkf1KGePU6zcd3AVU+cKctqIp/o02M pbC9MTYLkHqFMYJXQe/S5NvwjZVCeVTlL/G0+mjoO93uvk/hwz4bPycC/35w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1758011050; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=jmvHZRrOY5BQMprU9SL2HTOQI4p9mx8IlMUJSz0ZsUg=; b=BIbBmj8fZ1noo509zCC5yMQVO5bfTnQeZ4mjweiTzk95/SQQJtcYZpoQXYtUFZeUWDQDJ 1KsHw+DROYeuYADDiS20lQotjAsdBCjhJe4vKheo4P/qvmwO818hL7ApQfQXIQI/iZG5+8R /ZecPWb5eHS8pMBtr3TNDBp9jNoF6ldooa5LGjWsMl2xTHSU5tJWTzWFdKVg0wcq/zYmmE6 P43O8Rx2QlljjAWcI6ek1PE/YItdL/G8OYe5aFzwPPw+IfYKdRcgw1ndUaTXg8LeThrJOY5 +Uz8UJQw1NqzucXW5xyeEtVN63Btsa6Z0gT9uK8flJYFFo2+VKb6G/+N2UCw== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1758011035; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=I4c3lKClvdN8PMzNwpIZRMK53wT9Y24TAjyKGXjBFTI=; b=aVgF99hpeBBBqCfl6tqMmPC8YnIVILy443mS07kvPqdIo8Oza5zd2pwm0aJhHbnggXgRW o+GkU/O50Z76mbOkS35Rz+hmQI0jfS6ATQC6L6SjMiHW68tOcpxF9pCP/1nJbAFdyuGsIAI 8nlVEIj1xN7mLvPiZ71WCHbule7uXRyBiR9+JFoi8rxIQCpn8HL7OCVXVeCglLPcZcYOPx+ L3Po3q7JwqAJy3mu8irdkWS6H1O1Fg1r4jDNSeRYmNDvEF8xG9dBn099A3Drw70+gKuNzty TCxl5ppTdOlToXU5lTb6Pfk5WHluY5FE3YsDI3HT6F6/YpJ6pQ2NKMgpxBsg== Received: from ed19c606a818 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 7408D68E8B6 for ; Tue, 16 Sep 2025 11:23:55 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Sep 2025 08:23:54 -0000 Message-ID: <175801103573.25.10133309167585680872@463a07221176> Message-ID-Hash: 2JYCL5LUGVISUZ44ZAEOW5A2LEI46M3T X-Message-ID-Hash: 2JYCL5LUGVISUZ44ZAEOW5A2LEI46M3T X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec/qsvdec: fix refcount leak in two-stage QSV init (PR #20532) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: hajin-chung via ffmpeg-devel Cc: hajin-chung Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20532 opened by hajin-chung URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20532 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20532.patch The QSV decoder uses a two-stage initialization when a stream header is first processed. The first stage, inside qsv_decode_header(), creates a temporary hw_frames_ctx to get a session for parsing. The second stage, back in qsv_process_data(), creates the final hw_frames_ctx with the correct stream parameters. The temporary hw_frames_ctx was being abandoned without all of its references being released, leading to a leak of the context itself and, in turn, a leak of the hw_device_ctx it referenced. This prevented the QSV thread pool from being shut down correctly in long-running applications. The temporary hw_frames_ctx holds three references, including one from the internal `mids` array. This fix resolves the leak by explicitly unreferencing all known holders of the temporary context after it has been used for header parsing and before the final context is created. >>From e2517ec684b3478937fb2e3c0651eee5a2ffe5e2 Mon Sep 17 00:00:00 2001 From: hajin-chung Date: Tue, 16 Sep 2025 17:13:01 +0900 Subject: [PATCH] avcodec/qsvdec: fix refcount leak in two-stage QSV init The temporary hw_frames_ctx created for header parsing was not being fully released, leading to a leak. Explicitly unreference the temporary context after use to resolve the leak. Signed-off-by: hajin-chung --- libavcodec/qsvdec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index 144cf5b9e9..a85c1785cf 100644 --- a/libavcodec/qsvdec.c +++ b/libavcodec/qsvdec.c @@ -202,6 +202,7 @@ static int qsv_init_session(AVCodecContext *avctx, QSVContext *q, mfxSession ses MFXClose(q->internal_qs.session); q->internal_qs.session = NULL; } + av_refstruct_unref(&q->frames_ctx.mids); av_buffer_unref(&q->frames_ctx.hw_frames_ctx); q->frames_ctx.hw_frames_ctx = av_buffer_ref(hw_frames_ref); -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org