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 B547649881 for ; Tue, 20 Feb 2024 17:10:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9C20E68D22C; Tue, 20 Feb 2024 19:10:50 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 065AB680616 for ; Tue, 20 Feb 2024 19:10:43 +0200 (EET) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 288461060325 for ; Tue, 20 Feb 2024 17:10:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1708449042; 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=+ucQn8l2Hbjn/87Szm3qJxmyW6w8qEU8h9dqSaKeuD0=; b=NpmXmVxWqJ6bqjX1/X1fL52iUo6XZzfO6Q/v5k2MeZum/7zTJkmsSqeqgTY64C2g ply2PTSI3rjiN/TwhtxLLDBrwts/EJDd/i3wb0os6c+U1qETXfFOgbFAI02XqQlCH1b 02+Wk9701AwFDdZqrKQ85XNCN8y3DDJJ2VFp5GHkNRDYu3a/ekxHwxS2lAPETIhaJS8 Y7c7QaV4Rq2OgMB4upVPERZqjjkIvPYERoJ2y0BoG3zqcyQcf2TZqn6E6dPA3LF4FHB Gntn4TX6o3yZq9TqW77LglWNYck1rJ7PKseuiXf3mCengCJreItQL8svwkzMqLMKOo5 sOOocOBLCQ== Date: Tue, 20 Feb 2024 18:10:42 +0100 (CET) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: <20240220120858.317766-1-quinkblack@foxmail.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH 3/5] avutil/hwcontext_vulkan: Fix leaks when semaphore creation fails 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: Feb 20, 2024, 13:10 by quinkblack@foxmail.com: > From: Zhao Zhili > > --- > libavutil/hwcontext_vulkan.c | 30 +++++++++++++++++++----------- > 1 file changed, 19 insertions(+), 11 deletions(-) > > diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c > index a84713e621..c64094f31c 100644 > --- a/libavutil/hwcontext_vulkan.c > +++ b/libavutil/hwcontext_vulkan.c > @@ -1807,23 +1807,30 @@ static void vulkan_frame_free(AVHWFramesContext *hwfc, AVVkFrame *f) > VulkanDevicePriv *p = hwfc->device_ctx->internal->priv; > FFVulkanFunctions *vk = &p->vkctx.vkfn; > int nb_images = ff_vk_count_images(f); > + int nb_sems = 0; > + > + while (nb_sems < FF_ARRAY_ELEMS(f->sem) && f->sem[nb_sems]) > + nb_sems++; > + > + if (nb_sems) { > + VkSemaphoreWaitInfo sem_wait = { > + .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO, > + .flags = 0x0, > + .pSemaphores = f->sem, > + .pValues = f->sem_value, > + .semaphoreCount = nb_sems, > + }; > > - VkSemaphoreWaitInfo sem_wait = { > - .sType = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO, > - .flags = 0x0, > - .pSemaphores = f->sem, > - .pValues = f->sem_value, > - .semaphoreCount = nb_images, > - }; > - > - vk->WaitSemaphores(hwctx->act_dev, &sem_wait, UINT64_MAX); > + vk->WaitSemaphores(hwctx->act_dev, &sem_wait, UINT64_MAX); > + } > > vulkan_free_internal(f); > > for (int i = 0; i < nb_images; i++) { > vk->DestroyImage(hwctx->act_dev, f->img[i], hwctx->alloc); > vk->FreeMemory(hwctx->act_dev, f->mem[i], hwctx->alloc); > - vk->DestroySemaphore(hwctx->act_dev, f->sem[i], hwctx->alloc); > + if (f->sem[i]) > + vk->DestroySemaphore(hwctx->act_dev, f->sem[i], hwctx->alloc); > vkDestroySemaphore should already check for NULL, though? _______________________________________________ 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".