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 9A25B47DB5 for ; Fri, 27 Oct 2023 04:46:56 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BE47C68CBFC; Fri, 27 Oct 2023 07:46:53 +0300 (EEST) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93D4268CBE7 for ; Fri, 27 Oct 2023 07:46:47 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 104801060166 for ; Fri, 27 Oct 2023 04:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1698382006; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:References:Sender; bh=tSHIIYk42HUAeBfdqVU1ZUjFoPTFsOqvr9mIhV+rszg=; b=y00DI4XY98uzkwmkTYsG9gbjwaUU5EBQQVVpcYl2qBThOgq9dNqS+DyNRKSiXcUa OfTs1c8srlAl0MU5oeKBouIkiwsBiySDx+bUup0QjgAuJW1xF/jj1CougHlzlYF0yhD iXKlPv/Hn5LgdH+MC0y8Lhzh2qoj6ukkL801ro/wep11i9dNBB4X8SjPlH359LKtLEj m020A8ZIMUtoOX424senMVcnmahuQUtyfdmF3R9iKprwGlO6ugeatGSYWNDI78IWNjj dZrcFyocSlS26ZZUIh9id+/uyhBsrICX8l50hbBnsu1uZ5fVBvo6wRtVjrDRVKC3xyx xu3HMQjglg== Date: Fri, 27 Oct 2023 06:46:46 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avutil/hwcontext_vulkan: fix memleak when device_create is skipped 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 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: Oct 27, 2023, 05:53 by quinkblack@foxmail.com: > From: Zhao Zhili > > --- > libavutil/hwcontext_vulkan.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > index 4adcc0e839..8dd40cb66f 100644 > --- a/libavutil/hwcontext_vulkan.c > +++ b/libavutil/hwcontext_vulkan.c > @@ -1164,6 +1164,11 @@ static int setup_queue_families(AVHWDeviceContext *ctx, VkDeviceCreateInfo *cd) > return 0; > } > > +/* Only resources created by vulkan_device_create should be released here, > + * resources created by vulkan_device_init should be released by > + * vulkan_device_uninit, to make sure we don't free user provided resources, > + * and there is no leak. > + */ > static void vulkan_device_free(AVHWDeviceContext *ctx) > { > VulkanDevicePriv *p = ctx->internal->priv; > @@ -1183,15 +1188,20 @@ static void vulkan_device_free(AVHWDeviceContext *ctx) > if (p->libvulkan) > dlclose(p->libvulkan); > > + RELEASE_PROPS(hwctx->enabled_inst_extensions, hwctx->nb_enabled_inst_extensions); > + RELEASE_PROPS(hwctx->enabled_dev_extensions, hwctx->nb_enabled_dev_extensions); > +} > + > +static void vulkan_device_uninit(AVHWDeviceContext *ctx) > +{ > + VulkanDevicePriv *p = ctx->internal->priv; > + > for (uint32_t i = 0; i < p->nb_tot_qfs; i++) { > pthread_mutex_destroy(p->qf_mutex[i]); > av_freep(&p->qf_mutex[i]); > } > av_freep(&p->qf_mutex); > > - RELEASE_PROPS(hwctx->enabled_inst_extensions, hwctx->nb_enabled_inst_extensions); > - RELEASE_PROPS(hwctx->enabled_dev_extensions, hwctx->nb_enabled_dev_extensions); > - > ff_vk_uninit(&p->vkctx); > } > > @@ -3702,6 +3712,7 @@ const HWContextType ff_hwcontext_type_vulkan = { > .frames_priv_size = sizeof(VulkanFramesPriv), > > .device_init = &vulkan_device_init, > + .device_uninit = &vulkan_device_uninit, > .device_create = &vulkan_device_create, > .device_derive = &vulkan_device_derive, > LGTM Thanks _______________________________________________ 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".