From patchwork Tue Jun 13 04:21:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lynne X-Patchwork-Id: 42053 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp3425429pzb; Mon, 12 Jun 2023 21:21:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hd/e6QOxV6l4r5QqUX2Xxb2NqEWpoQyr37AcxhnxV9aEjDoKyxHEnlYrI0B/v3zlmUPrl X-Received: by 2002:a17:907:2d0f:b0:965:6075:d0e1 with SMTP id gs15-20020a1709072d0f00b009656075d0e1mr12279009ejc.72.1686630078656; Mon, 12 Jun 2023 21:21:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686630078; cv=none; d=google.com; s=arc-20160816; b=Sg/bqBQ35EiYnBzWMpanqjBfoZtBbie37x2IaGzxHkvlsqsA5fLdHLk3+y0y6ctCzU vngcgKFlUvILmi4HwNc7KgH6FmJEWoUMr53GYex6fwMjRYLI0OoLSSeNH55k1zAeObsQ k1gZ5txesond7Q0141/y4UrAQxiGL+d29x6zTMRG+LzrZczCGdGEuhLZpt85497gH++I eKOkXFpjS6zt0bhUcFBH4HbpNCwi6gWLste0RzzxkvulJzFs9FVuOADnLreoNg+ja2ul VwJhIZt+N9PavxKzoGIi1kkHO1BS/+YZgjI8Kk2bMj1QpK5IEEbmD0j83df5rjaOTAtu LTKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:to:from:date :dkim-signature:delivered-to; bh=p6b3NBUzCL6o6+ZdBfGQGEX1h79tCgb+GGFqcvTnRZA=; b=KDlpdCbPkXK4FAVhGg4DaiJMPc/r69+D8Nx7MRmrWlG0/kz2jxx21mNAh44zQpwF++ d1AGF1q7DfEs16+pMRAnS93gBFxfuoNQ2s43iLctv9gg+UTZaKYJy7NEa1fs+nCofa+m DqLWzkPXSAyUCqGuTVXTQvB6MKjTT5eYZ/7gTA6Yj1N1PCBpO7R9i97tOVae4CKtrFBN QBDFvIMs59hTP2zgFtqKswDpo/NSXs0RdaJB6juff4tSdzgqQKSykmmEcK84uV4KxqSN crdqkXTDuGL5eSs/E55IwfHw83bQRupLGFzWZqDnGqz8GLT0NtZDzO8Pp6a3ZzLVDUeI 1A3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=W0NQw0HJ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r4-20020a1709062cc400b009722bcd89fesi5704984ejr.543.2023.06.12.21.21.17; Mon, 12 Jun 2023 21:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@lynne.ee header.s=s1 header.b=W0NQw0HJ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=lynne.ee Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0A8C468C37B; Tue, 13 Jun 2023 07:21:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 623AA68C37B for ; Tue, 13 Jun 2023 07:21:08 +0300 (EEST) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 709E710601E3 for ; Tue, 13 Jun 2023 04:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1686630068; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type: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=Gx2x+3xHhaHrq+SXFL+nGfl6nGbPXxrHSLUbQDEHjhI=; b=W0NQw0HJBYm0q3LBexu/KAt5CYHI4wLH4g1BXZyT8N/Nl4ORdRQ7AqXHaZ6ahlk1 g6n8W1fc2SkoIhlgaLP0/6s3X8uQdMdzZoteSxrNRdXhITHtsQbza8aUutwewb58zJw ZZCQPK1hKsUk2FpRlrYTazRqUiAOSSAkHNa4p+A2e7aQijn58byXOhOfsIUHpZZiqBc k2Y2GTCO8z144l5/y9N+boIiCH5CHADrsEVRvu6WbX28CAMu9dCa3qnIal/2MITJaCW X+H01OGXgQNwWS4G+BNEUTk4FnQkpcarkks3lSTLnCqrp1/xNb/daMfhORhZiOXZYGF o9OkZ1qlKg== Date: Tue, 13 Jun 2023 06:21:08 +0200 (CEST) From: Lynne To: FFmpeg development discussions and patches Message-ID: In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] hwcontext_vulkan: free temporary array once unneeded 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: H2eP52mdXlvU Fixes a small memory leak. This also prevents leaks on malloc/mutex init errors. Does not depend on any other patches. Patch attached. From 52cdd121f986d36d18b95077f9c748bc9d7d918d Mon Sep 17 00:00:00 2001 From: Lynne Date: Tue, 13 Jun 2023 04:36:54 +0200 Subject: [PATCH 4/5] hwcontext_vulkan: free temporary array once unneeded Fixes a small memory leak. This also prevents leaks on malloc/mutex init errors. --- libavutil/hwcontext_vulkan.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c index c86229ba65..ca802cc86e 100644 --- a/libavutil/hwcontext_vulkan.c +++ b/libavutil/hwcontext_vulkan.c @@ -1427,24 +1427,31 @@ static int vulkan_device_init(AVHWDeviceContext *ctx) vk->GetPhysicalDeviceQueueFamilyProperties(hwctx->phys_dev, &qf_num, qf); p->qf_mutex = av_calloc(qf_num, sizeof(*p->qf_mutex)); - if (!p->qf_mutex) + if (!p->qf_mutex) { + av_free(qf); return AVERROR(ENOMEM); + } p->nb_tot_qfs = qf_num; for (uint32_t i = 0; i < qf_num; i++) { p->qf_mutex[i] = av_calloc(qf[i].queueCount, sizeof(**p->qf_mutex)); - if (!p->qf_mutex[i]) + if (!p->qf_mutex[i]) { + av_free(qf); return AVERROR(ENOMEM); + } for (uint32_t j = 0; j < qf[i].queueCount; j++) { err = pthread_mutex_init(&p->qf_mutex[i][j], NULL); if (err != 0) { av_log(ctx, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", av_err2str(err)); + av_free(qf); return AVERROR(err); } } } + av_free(qf); + graph_index = hwctx->queue_family_index; comp_index = hwctx->queue_family_comp_index; tx_index = hwctx->queue_family_tx_index; -- 2.40.1