From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41BA63B95FF for ; Wed, 14 Oct 2026 11:37:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791977856; cv=none; b=C4XuoRCY0VY6NMCAy0S2Mk8q8P/3ikb9gPmrH6S1k3iyEcqP1JWfOL06aQhivrBcwndDUivzqhw7YU/XWPBm906XNkzn23M1VNJhCdxAwVSZZ7/dxPAk5JrOiLrPCcF4cSiGI8ncD7OXT3dgOaLxzVVTeu+7h43l5LRD5qN/rWY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791977856; c=relaxed/simple; bh=4m6waPUkhomHnW0R2SZtL391TEfAQDn4Lg/PtkdlnYY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=PB3PJwVF9gfc0laQZypieOyEZvHthCfeff1XrlcUE+Z3tRSnXzMpBNMkke2vA86n7aWdDIovoV8YNme/IRkmqPORvM0FGtYYgh8DxrB2HG6lNYjKfZLRlKcZMLevs0xhA/G07Zt2qeNG/hLluTWobp0ymD3XvqjAAeN900vrwkY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=WimA8nXl; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="WimA8nXl" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 80DB64E41223; Wed, 14 Oct 2026 11:37:32 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4D64760368; Wed, 14 Oct 2026 11:37:32 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E41B010328B3C; Wed, 14 Oct 2026 13:37:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1791977846; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=V4ymEuqTqyaGq+HF/qthlrZ+HnGnQbv0+xl6gccW0qw=; b=WimA8nXlV/g+Y+ZUIyVT/eGUQPHsoHwQzPZbgc659ZiDq5n/nyjMkKmB2jsahsmpXVBHUP y1WXOeZ1wKwgk3+PYlI4eB6+NWmltzXZNzbCp66isfr3QC2VMC+z6WQKBD8roI+iEaX95N toqaPVbA7yACgD77dKlLz4jiqTb17fQVy/V3wPWUrU/V0b3c9ByJcdYZKXkeq9VOaFVatD +lIN5IIQC3cHqry8fc65sYSF6slJRSPpzw+e3PFRpHrosx3UgmgL7aCXDEAOH5X/op4zVi L9j25MgZLf3mpLJRNOfaH+tnn4VMCddzGSYn4eIOr7MFSwrAFVpBkPMVKTPnwQ== Message-ID: <1e6bee3e-a4fd-4cdb-9c42-5cee57e3ed83@bootlin.com> Date: Wed, 14 Oct 2026 13:37:19 +0200 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net 2/3] net: stmmac: free RX resources when TX allocation fails To: Karl Mehltretter , Andrew Lunn , netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexandre Torgue , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Joao Pinto , Giuseppe Cavallaro , Srinivas Kandagatla , Ong Boon Leong , bpf@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: Content-Language: en-US From: Maxime Chevallier In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Last-TLS-Session-Version: TLSv1.3 Hi, On 10/14/26 08:27, Karl Mehltretter wrote: > alloc_dma_desc_resources() allocates every RX queue before allocating > TX queues. If TX allocation fails, its error path only frees TX > resources and leaks all RX resources. > > Free the RX resources after the TX allocator unwinds its queues. > > Found by inspection. On a BeagleV Ahead (TH1520), forcing TX DMA > metadata allocation to fail left the RX cleanup event absent. With this > change, both TX and RX resources were released. > > Fixes: 71fedb0198cb ("net: stmmac: break some functions into RX and TX scopes") > Assisted-by: LLM > Signed-off-by: Karl Mehltretter Also covered by https://lore.kernel.org/netdev/20261012142458.2845385-1-dinghui1111@163.com/. Thanks, Maxime > --- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 495ff7aef..8fd7d2173 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -2425,6 +2425,8 @@ static int alloc_dma_desc_resources(struct stmmac_priv *priv, > return ret; > > ret = alloc_dma_tx_desc_resources(priv, dma_conf); > + if (ret) > + free_dma_rx_desc_resources(priv, dma_conf); > > return ret; > }