🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10255

[PATCH] net: stmmac: free RX resources when TX allocation fails

#10255
From: Wentao Liang
Date: Tue, 03 Nov 2026 10:28
36 lines
9519 bytes
alloc_dma_rx_desc_resources() unwinds the RX queues when the RX
allocation itself fails, and alloc_dma_tx_desc_resources() unwinds the
TX queues when the TX allocation fails.  But when the RX allocation
succeeds and the TX allocation then fails, the RX queues that were
already set up are left behind.  stmmac_setup_dma_desc() only frees the
dma_conf on this path, so the RX DMA rings, page pools and socket
buffers are leaked.

Release the RX queues from alloc_dma_desc_resources() when the TX
allocation fails, before the caller drops the partially populated
dma_conf.

Fixes: ba39b344e924 ("net: ethernet: stmicro: stmmac: generate stmmac dma conf before open")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 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 9ded31150fbe..049d85b3e25f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -2446,6 +2446,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;
 }
-- 
2.34.1
Technical Details
Message-ID: <20261103102857.1340748-1-vulab@iscas.ac.cn>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355440-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355440-linux-kernel-netdev=dewy.ru
From: vulab@iscas.ac.cn (Wentao Liang)
Newsgroups: linux.kernel.netdev
Subject: [PATCH] net: stmmac: free RX resources when TX allocation fails
Date: Tue,  3 Nov 2026 10:28:57 +0000
Organization: Usenet Network
Message-ID: <20261103102857.1340748-1-vulab@iscas.ac.cn>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3151644"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mwPybkWMrjYM5Dp3lmC+BRsTKgw= sha256:tSEFDRFZSGssf5b32kpY9PUflifEoNJwPm5KAgdiEF0=
	sha1:4EfUxtmb+wuWpsbHN/UzVSQs2pM= sha256:GHETuD64himChwbNwG9bSllpP0EN+S386oQyiT4k34A=
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 46BC011281E; Tue,  3 Nov 2026 14:19:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.507
X-Spam-Status: No, score=0.507 tagged_above=-9999 required=6.31
	tests=[HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=no autolearn_force=no
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 hKkKvW6JcRuj;
	Tue,  3 Nov 2026 14:19:24 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355440-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 0CA921127C8; Tue,  3 Nov 2026 14:19:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 66E4C61B01E; Tue,  3 Nov 2026 10:39:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1793701742;
	b=ncL0BSWUXfK/AaoCIiN8SOBdSYegMHgJiO5sani9bm7YsDw2DtTFqotRKsUccN2pR84W
	 RKT8vT55YEjNiiEhqpac38tW9cQ08ySnAv/LfsqL1J1099imCWDny/uQNrwi0E5XJzVh0
	 w7DP5S9hbODgWIyYPHZ3zlpvJrW4QiIQwebPUiqXL7Vtr8DnVrcLCYy0K3TsqLqgBGHXw
	 lykuMkgH9D1IOdZZhfbcdHS6M42xKQpwQOsT1NxvubfCkqwPgwjjo5ttpoBhGHFbxAjqh
	 IAmY6WW3TwXV8qJVI0qPxwGip9dFyqJ4NKGzDvIaslS3IGpzTBaN4MYhzgTwA3NmQnw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793701742;
	h=X-Original-To:Received:DMARC-Filter:Received:From:To:Cc:Subject:Date:
	 Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:
	 List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
	 Content-Transfer-Encoding:X-CM-TRANSID:X-Coremail-Antispam:
	 X-CM-SenderInfo;
	bh=jqrLKz9LrRsFxqXYepb2D+Y6GF21YYOQi1/zUhtLyRg=;
	b=qiyd19KRtNR8XqiNAp8R7CQfRbsQu7BivP1VNbzRQ5Zb4IqKm1keQv1Nuett0nfSByoF
	 bbPiGBbU6vi8VQzYq+5kMtWmPmaz5VW3L+c8Bc4+D6+E/X/t8CnqL60znA6OZq8JyURjb
	 7wjF66TBUCqrT/lsTVDRJLZTxlh8B46vBUOcphwHnpNU04dRCbrnmKsbFhwumvSbYyaWi
	 HHekH3gjxfqX7ADSRpVfR2H8H57K/VkUWpyL446szmU6EsY66yj6e225q5T5wG+FBqjhF
	 SS9D0HQHa39Dx5Tyw8dMASsHmBu8nUngy25oCI3d1Hlu//zOGQ+mQa4ek7cYz4KG6CA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dmarc=none header.from=iscas.ac.cn;
	spf=pass smtp.mailfrom=iscas.ac.cn;
	arc=fail 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 4F901606C5F7;
	Tue,  3 Nov 2026 10:29:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=159.226.251.81
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793701741;
	b=1+OAsmyK1I8UE1OI9eVDbb7e7bKtngMTZfyud5RR+yBENDsmUQypwMWy6zpHQ0e3Tm1j
	 xMByqFagkVufHG7+IOSgWEpQkk/+vDM/epRHK9vFZqgEw+3ONyAM1vHXGYGM3fuFRv2KU
	 B8iipebQ9YVVA82QlKRQqJDItZSUyrft3Wibj+rK5x7FmmT6zUOxfGKERJnoQ/6YckNLL
	 bIC8fuc8UQ5skn+ur3Kbq8UBCP+cYmt1DH88miHejDjnH3pzsWRRWoeeEbLW/eCfD9lsJ
	 doC2QuuyJ8AgHBj+nTult5BLIidt7U43p7bryWpeh8rL7jH3rlUXyjxyIyVUBXZW/xw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793701741;
	h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:
	 MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID:
	 X-Coremail-Antispam:X-Originating-IP:X-CM-SenderInfo;
	bh=jqrLKz9LrRsFxqXYepb2D+Y6GF21YYOQi1/zUhtLyRg=;
	b=KKWNMgwM/VErlO9hUW/w2z1J4nekDMxVuAW9DMBrq+D5VJdnw5aRqnLRqg4wkkyvrodv
	 U+CESW0eobsO3axZAcstyfleIWyv5ODkjdLBKjxsTdv61dNtJ/ibeDdoSBrtnu/RXZ7gk
	 LFUMlzfndb4//8NE1Z7fkVQ7kXyh/32Lhz27zuW3KiftPMh9sNPmPgWgarKGhBAi8yiNu
	 CbKYPD0wb5R3BONUxz7tdgDJHhWJbxFxvH2MvPVAjDtUvchcs32O4LiogKHAh0EuxrvAP
	 XWsSgSfyfeS2H0bOkyaE2dNopoebngdNeYOtiuVW86CWhSEi78cy5e5FuVq7JV3u1tg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=none header.from=iscas.ac.cn;
	spf=pass smtp.mailfrom=iscas.ac.cn;
	arc=none smtp.remote-ip=159.226.251.81
X-Received: from cstnet.cn (smtp81.cstnet.cn [159.226.251.81])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8252760A5BC4;
	Tue,  3 Nov 2026 10:29:00 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8252760A5BC4
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn
X-Received: from dfae2b116770.home.arpa (unknown [36.110.52.2])
	by APP-03 (Coremail) with SMTP id rQCowAC3wZJgt+lqsak7AA--.3028S2;
	Tue, 03 Nov 2026 18:28:48 +0800 (CST)
X-Cc: netdev@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
X-Mailer: git-send-email 2.34.1
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-CM-TRANSID: rQCowAC3wZJgt+lqsak7AA--.3028S2
X-Coremail-Antispam: 1UD129KBjvJXoW7uw4DZr13ZF4UJr43Zr43KFg_yoW8XryUpw
	s3ZayUKr9Fqr4fJw4DJw109Fy3uaySyr4UWa1xZa1fWF43uryjgr1aqrWUXF1UJFW8ZF1a
	vr4qk3W3CF1DA3JanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2
	9KBjDU0xBIdaVrnRJUUU9a14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0
	rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02
	1l84ACjcxK6xIIjxv20xvE14v26ryj6F1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U
	JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc
	CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E
	2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v26F4UJVW0owAm72CE4IkC6x0Yz7v_Jr
	0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E
	8cxan2IY04v7MxkF7I0En4kS14v26r1q6r43MxAIw28IcxkI7VAKI48JMxC20s026xCaFV
	Cjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWl
	x4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r4j6r
	yUMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWU
	JVWUCwCI42IY6I8E87Iv67AKxVWxJVW8Jr1lIxAIcVC2z280aVCY1x0267AKxVWxJr0_Gc
	JvcSsGvfC2KfnxnUUI43ZEXa7VU8jQ6JUUUUU==
X-CM-SenderInfo: pyxotu46lvutnvoduhdfq/1tbiDAMAA2rpnOFxBAAAsH