Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Xiang, Haihao via ffmpeg-devel" <ffmpeg-devel@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: "김현호(HYUN HO KIM)" <hh3.kim@hanwha.com>,
	"Xiang, Haihao" <haihao.xiang@intel.com>
Subject: [FFmpeg-devel] Re: [PATCH] avcodec/qsv: Multiple calls to ff_qsv_init_session_frames() cause handle and memory leaks.
Date: Fri, 21 Nov 2025 16:33:28 +0000
Message-ID: <DM3PR11MB87578A25A5443C67B00254519ED5A@DM3PR11MB8757.namprd11.prod.outlook.com> (raw)
In-Reply-To: <67afd6cd2472418eb4668f64f9f3a0d3@hanwha.com>



> -----Original Message-----
> From: 김현호(HYUN HO KIM) via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
> Sent: Tuesday, October 28, 2025 20:28
> To: ffmpeg-devel@ffmpeg.org
> Cc: 김현호(HYUN HO KIM) <hh3.kim@hanwha.com>
> Subject: [FFmpeg-devel] [PATCH] avcodec/qsv: Multiple calls to
> ff_qsv_init_session_frames() cause handle and memory leaks.
> 
> Within qsvdec.c, ff_qsv_init_session_frames() is typically called twice during
> decoder initialization. Although qsv_create_mids() may be called if avctx-
> >hw_frames_ctx exists, this procedure causes memory and handle leaks
> because the existing created resources are merely set to NULL before
> ff_refstruct_unref() is called.
> 
> Signed-off-by: Hyunho Kim <hh3.kim@hanwha.com>
> ---
>  libavcodec/qsv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
> index 8a3dc95706..d8ddf85392 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -1133,13 +1133,13 @@ int ff_qsv_init_session_frames(AVCodecContext
> *avctx, mfxSession *psession,
>          return ret;
> 
>      if (!opaque) {
> +        /* clean up the exist mids */

s/exist/existing 

> +        ff_refstruct_unref(&qsv_frames_ctx->mids);
>          qsv_frames_ctx->logctx = avctx;
> -        qsv_frames_ctx->mids = NULL;	

You may remove only this line, without any other changes.

Thanks
Haihao

>          qsv_frames_ctx->nb_mids = 0;
> 
>          /* allocate the memory ids for the external frames */
>          if (frames_hwctx->nb_surfaces) {
> -            ff_refstruct_unref(&qsv_frames_ctx->mids);
>              qsv_frames_ctx->mids = qsv_create_mids(qsv_frames_ctx-
> >hw_frames_ctx);
>              if (!qsv_frames_ctx->mids)
>                  return AVERROR(ENOMEM);
> --
> 2.48.1.windows.1
> 
> _______________________________________________
> ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
> To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

      reply	other threads:[~2025-11-21 16:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-28 12:28 [FFmpeg-devel] " 김현호(HYUN HO KIM) via ffmpeg-devel
2025-11-21 16:33 ` Xiang, Haihao via ffmpeg-devel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DM3PR11MB87578A25A5443C67B00254519ED5A@DM3PR11MB8757.namprd11.prod.outlook.com \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=haihao.xiang@intel.com \
    --cc=hh3.kim@hanwha.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git