Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avutil/hwcontext_qsv: register free function for device_derive
@ 2023-06-16  7:27 Tong Wu
  2023-06-19  3:52 ` Xiang, Haihao
  0 siblings, 1 reply; 2+ messages in thread
From: Tong Wu @ 2023-06-16  7:27 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Tong Wu, Wenbin Chen

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 <tong1.wu@intel.com>
Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavutil/hwcontext_qsv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index 4ed4242ddf..713dc90ffd 100644
--- a/libavutil/hwcontext_qsv.c
+++ b/libavutil/hwcontext_qsv.c
@@ -2094,6 +2094,9 @@ static int qsv_device_derive(AVHWDeviceContext *ctx,
                              AVDictionary *opts, int flags)
 {
     mfxIMPL impl;
+
+    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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avutil/hwcontext_qsv: register free function for device_derive
  2023-06-16  7:27 [FFmpeg-devel] [PATCH] avutil/hwcontext_qsv: register free function for device_derive Tong Wu
@ 2023-06-19  3:52 ` Xiang, Haihao
  0 siblings, 0 replies; 2+ messages in thread
From: Xiang, Haihao @ 2023-06-19  3:52 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wu, Tong1, Chen, Wenbin

On Vr, 2023-06-16 at 15:27 +0800, Tong Wu wrote:
> 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 <tong1.wu@intel.com>
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavutil/hwcontext_qsv.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index 4ed4242ddf..713dc90ffd 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -2094,6 +2094,9 @@ static int qsv_device_derive(AVHWDeviceContext *ctx,
>                               AVDictionary *opts, int flags)
>  {
>      mfxIMPL impl;
> +
> +    ctx->free = qsv_device_free;

ctx->user_opaque is NULL, which might cause segmentation fault in
qsv_device_free().

Thanks
Haihao

> +    
>      impl = choose_implementation("hw_any", child_device_ctx->type);
>      return qsv_device_derive_from_child(ctx, impl,
>                                          child_device_ctx, flags);

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-19  3:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-16  7:27 [FFmpeg-devel] [PATCH] avutil/hwcontext_qsv: register free function for device_derive Tong Wu
2023-06-19  3:52 ` Xiang, Haihao

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