From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88DBE28BA95 for ; Mon, 20 Oct 2025 22:00:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760997613; cv=none; b=Obss2U+LOZMQLU3pwebYsZUfjnXsiX6yCo30A8150/q9bnXEACm5IejYJtQ/a2mGtXok/w+KmRdrVWuGGeK4Z0jqMCVAyIyoCy6DJeXSYFk1NjrBKiL/nTA99reazGi37L9Y7f94vGerBpdkMIA8+bvEAYwqckgxmJR7Ur2s2P8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760997613; c=relaxed/simple; bh=L679A6msYvHUkm/JwWRb7m0hy/SGgv6lgw6Wc6utwDk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eatJ1F9xvU+iNkOq4xRoBICPRjAD+6V0blAm7W5i581qkhbiZIPB2NrNj8+I5zKUKYpKHulruu3DtDOe/nCiXFbTnQ355p/U3znhSNhNQq5srLXiucCnrvrOUKmpJ2sHfw2Ojwc0f1tstgjfjfBfhTe9UEPBrXROkEVT7l9obro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 902AC1007 for ; Mon, 20 Oct 2025 15:00:01 -0700 (PDT) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 372563F63F for ; Mon, 20 Oct 2025 15:00:09 -0700 (PDT) Date: Mon, 20 Oct 2025 22:59:55 +0100 From: Liviu Dudau To: Akash Goel Cc: boris.brezillon@collabora.com, steven.price@arm.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, nd@arm.com Subject: Re: [PATCH v2] drm/panthor: Fix potential memleak of vma structure Message-ID: References: <20251020200243.1324045-1-akash.goel@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20251020200243.1324045-1-akash.goel@arm.com> On Mon, Oct 20, 2025 at 09:02:43PM +0100, Akash Goel wrote: > This commit addresses a memleak issue of panthor_vma (or drm_gpuva) > structure in Panthor driver, that can happen if the GPU page table > update operation to map the pages fail. > The issue is very unlikely to occur in practice. > > v2: Add panthor_vm_op_ctx_return_vma() helper (Boris) > > Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block") > Signed-off-by: Akash Goel Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/panthor/panthor_mmu.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c > index 6dec4354e378..63af8ee89b08 100644 > --- a/drivers/gpu/drm/panthor/panthor_mmu.c > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c > @@ -1146,6 +1146,18 @@ static void panthor_vm_cleanup_op_ctx(struct panthor_vm_op_ctx *op_ctx, > } > } > > +static void > +panthor_vm_op_ctx_return_vma(struct panthor_vm_op_ctx *op_ctx, > + struct panthor_vma *vma) > +{ > + for (u32 i = 0; i < ARRAY_SIZE(op_ctx->preallocated_vmas); i++) { > + if (!op_ctx->preallocated_vmas[i]) { > + op_ctx->preallocated_vmas[i] = vma; > + return; > + } > + } > +} > + > static struct panthor_vma * > panthor_vm_op_ctx_get_vma(struct panthor_vm_op_ctx *op_ctx) > { > @@ -2081,8 +2093,10 @@ static int panthor_gpuva_sm_step_map(struct drm_gpuva_op *op, void *priv) > ret = panthor_vm_map_pages(vm, op->map.va.addr, flags_to_prot(vma->flags), > op_ctx->map.sgt, op->map.gem.offset, > op->map.va.range); > - if (ret) > + if (ret) { > + panthor_vm_op_ctx_return_vma(op_ctx, vma); > return ret; > + } > > /* Ref owned by the mapping now, clear the obj field so we don't release the > * pinning/obj ref behind GPUVA's back. > -- > 2.25.1 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯