Article View: linux.kernel.netdev
Article #22460Re: [PATCH v5 net 2/4] net: hns3: fix page_pool leak in hns3_alloc_ring_memory error path
From: Simon Horman
Date: Wed, 25 Nov 2026 10:38
Date: Wed, 25 Nov 2026 10:38
26 lines
9061 bytes
9061 bytes
On Wed, Nov 18, 2026 at 09:03:28PM +0800, Jijie Shao wrote:
> In hns3_alloc_ring_memory(), when hns3_alloc_ring_buffers() fails for
> an RX ring, the error path jumps to out_with_desc, which frees the
> descriptor ring but does not destroy the page_pool that was just
> allocated by hns3_alloc_page_pool(). The page_pool and its pages are
> leaked.
>
> Destroy the page_pool in that error path as well. The pool is torn down
> before the descriptor ring here, which is the opposite of the order in
> hns3_fini_ring(); that is safe because hns3_alloc_ring_buffers() has
> already detached every buffer it attached, so hns3_free_desc() walks
> descriptors whose dma is zero and never hands a page back to the pool.
>
> Fixes: 93188e9642c3 ("net: hns3: support skb's frag page recycling based on page pool")
> Signed-off-by: Jijie Shao <shaojijie@huawei.com>
> ---
> Changes in v4:
> - Name hns3_fini_ring() instead of the non-existent
> hns3_free_ring_memory(), and drop "mirroring" because the destroy
> order differs. The pool is destroyed before the descriptor ring
> here, which is safe because hns3_alloc_ring_buffers() has already
> detached every buffer.
> v3: https://lore.kernel.org/all/20261030095633.377289-3-shaojijie@huawei.com/
Reviewed-by: Simon Horman <horms@kernel.org>
Technical Details
Message-ID:
<20261125103825.GP31322@horms.kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371235-linux-kernel-netdev=dewy.ruReferences:
<20261118130330.3026625-1-shaojijie@huawei.com> <20261118130330.3026625-3-shaojijie@huawei.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371235-linux-kernel-netdev=dewy.ru From: horms@kernel.org (Simon Horman) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH v5 net 2/4] net: hns3: fix page_pool leak in hns3_alloc_ring_memory error path Date: Wed, 25 Nov 2026 10:38:25 +0000 Organization: Usenet Network Message-ID: <20261125103825.GP31322@horms.kernel.org> References: <20261118130330.3026625-1-shaojijie@huawei.com> <20261118130330.3026625-3-shaojijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="183373"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gCqhdP8CE5PB3bXudEWRs3ks1dQ= sha256:1IGckLGgdN3HiRiaJE+EfKQcDJpSALBtivchvX5VGSs= sha1:thyDaQ9ElooKPjcTS31X8/5xZyg= sha256:DnWNN+HW64zwaY/vHtlnZOQGAduumG47vYma4bUbkIY= Content-Disposition: inline List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id E9B5C125E53; Wed, 25 Nov 2026 13:38:54 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0yZ0e2rVa6RC; Wed, 25 Nov 2026 13:38:47 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371235-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 57D3F125E52; Wed, 25 Nov 2026 13:38:38 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 966C63CA3D; Wed, 25 Nov 2026 10:38:34 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795603113; b=JmxOKD+LKwuP5hHk04Hu9Bc4LKG3TiRLdmXXzx7e51z8eXRjYev1nEUs/oabJOUaVlDj zZSmJLARcKIuRfCPJemdqRxhSkSb9LCahErzQ+R+jupmbBN/WOC79D5EJJT6YDAJILE6R f0EsnSLj4vymLso4rzihFHOJxZUNt4ObDQ2NMdGyxz3WjicMzSIwBgn5sXviOL+QqZ0yT 40+myk/p2eRm0BALrIuuhXDQ+5mhI5B/OV5iH99XXuDN+B++QrXJF4ED5E4pLFgAQQCcl 6gbUvWlFCZbAr/A/a+CeWzXGKsGLRou6IKuydNOPyklDLMCx07BCleWOpZUK1gAN4Nw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795603113; h=X-Original-To:Received:Received:DKIM-Signature:Date:From:To:Cc: Subject:Message-ID:References:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=DGmmdZ/+crnDPatnG/CIfOVgARayETg3HVMqTgIXG7A=; b=EdVr/Wt6zIm6/vfCrQMbSDbEUO/qcplEOxprxPhL+axDn/05Bhko1HWvXd9D+7QrZPFl yzSOu94PIyrMcbHuFLw73T0uxTbxfYwgAVcNLIt7cT8iCYNzMIo9o9maMAUnQYQuEJnxN SrIO+2rJmaG4jzWl8fCJWFOilzPDSivnLJpdjJLWHFfugE3Folrch2+7TJPvJDzxXj3VY fatnOLDekyUsSZ+0WHiL3FvUFg56xnUjMQtgxnPSpOVGw+ES01cwWJf5cMMGWSr8pKuJn 8t37p/5rW7voRm/01gGoeDmkjol0+VUqP+jibhve9m3HWWIQtw9H0N44ch4/2Vtsvdw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gqpD1aOJ; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8C877606A337; Wed, 25 Nov 2026 10:38:33 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gqpD1aOJ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795603112; b=1y1VncoSV39G7kJ/8P3/xXr4Z9qIraAf4sNZZMNjrxXHnkanj5wF0+hQM/bfowhVhOWk FMiSORwgJcHTiRbiO9KgZNM78fNQSXOGuyqghKGCftVI+d8U93L7J8e/aAtjDraVy/m0z i4sSJy3pHv6GSAQwrMKrc1UInmnzpy0aUrJ8ImMu8pbMppL9Ni3i2s8u+5AMCz5ljwB1i 922Nm2QaVCZXN4SWIPcXr7HS9Qyw7kbja4xE9bC4HHpT/3XG5rQyJO58cvYqHdnIOi/uQ Zm+vqZXXwiMIqc0pSQblnEvVYlcL4za9TokNxYr81SCjC2/6SbsB8/6WWtaBgRIyEbg== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795603112; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=DGmmdZ/+crnDPatnG/CIfOVgARayETg3HVMqTgIXG7A=; b=MfADsPgToERVywdm2YYnCCugFAFLFfrvSq3qUsJZdsM4XTsPUNfpjRZ3jjewK1BkrEKP us9Cr4YJVQALEN4TqZxybauBIPAyVWDAfbFIvtxs5BgBMEHtqBg0eCAjo4lOJdjtbsmpB rOjuO5qST6w7s1fgDqgBUHhSUP0Ktx+wyYnzSYjv4XmfyGjP21YfxNvl42K+hJsszYd9l W+256hCjUG5wd6zw5o/szf3vHiuCTZvy0rO5NSh2oh0oa5LJHKvOZsMkh0hxycY/HXs6w hwlcdsEzvOE8qCMPDPl0FVHuHwKT5qh5iGvLdpkyjMSvyyZCl2r+Mt7OHaM8fU+ytTQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gqpD1aOJ; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A97B7606A321; Wed, 25 Nov 2026 10:38:32 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 688521F000E6; Wed, 25 Nov 2026 10:38:29 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795603112; bh=DGmmdZ/+crnDPatnG/CIfOVgARayETg3HVMqTgIXG7A=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=gqpD1aOJnHWLGsEz/AD0gHJlL+gmPBIRDa1KO6ypl5/gYHxP60J0O212G77QC/Wba XEsPDMargv06e2KcGDqTGnEfL/ahwxNYDVHIQE4dZZ2F4PMQetG/FojN0/SY0MTolD G3spCn3alsEuJ093eHCbeu89OCowbleZ4bfRbSrBUWJNvZ1p56H8gjW/VJRfDmm9KB kk23Jb0nnV9989wYIGZpz/GR7R3PFN25bpczeeEbOGSK2iI9ol9B+GG2AZ13QsH0Ox cOVW1sKpuyOxvq3JVS70SV8A1qRtuemHtj3rzOSkSTJcWZuOa0G1PymTIWNyk/ULoE GI3c7cBD8xI1A== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch, shenjian15@huawei.com, liuyonglong@huawei.com, chenhao418@huawei.com, yangshuaisong@h-partners.com, ningwei15@huawei.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261118130330.3026625-3-shaojijie@huawei.com>