๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #5413

Re: [PATCH net v5 1/5] net: ethernet: mtk_wed: skip ring reset in wdma_tx_ring_setup for WED v3

#5413
From: netdev-bot+sashiko
Date: Tue, 20 Oct 2026 10:10
67 lines
10738 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] net: mtk_wed: memory leak of rx_ring and tx_ring on setup
  failure

--

> diff --git a/drivers/net/ethernet/mediatek/mtk_wed.c b/drivers/net/ethernet/mediatek/mtk_wed.c
> --- a/drivers/net/ethernet/mediatek/mtk_wed.c
> +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
> @@ -1938,7 +1938,7 @@ mtk_wed_wdma_tx_ring_setup(struct mtk_wed_device *dev, int idx, int size,
>  	wdma_w32(dev, MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_CPU_IDX, 0);
>  	wdma_w32(dev, MTK_WDMA_RING_TX(idx) + MTK_WED_RING_OFS_DMA_IDX, 0);
>  
> -	if (reset)
> +	if (!mtk_wed_is_v3_or_greater(dev->hw) && reset)
>  		mtk_wed_ring_reset(wdma, MTK_WED_WDMA_RING_SIZE, true);
>  
>  	if (!idx)  {
>

[Severity: High]
The change here looks fine to me. Since mtk_wed_wdma_tx_ring_setup()
is one of the failure points involved, I'm raising the ring teardown
changes later in this series here. That is the patch that gates
mtk_wed_free_ring() on MTK_WED_RING_CONFIGURED.

First, mtk_wed_free_rx_rings() walks dev->rx_ring[] but tests
dev->tx_ring[i].flags before calling mtk_wed_free_ring() on
dev->rx_ring[i]. That looks like a copy/paste slip. If tx_ring[i] was
never configured, an allocated rx_ring[i] is never freed. Should that
be dev->rx_ring[i].flags?

Second, mtk_wed_tx_ring_setup() and mtk_wed_rx_ring_setup() call
mtk_wed_ring_alloc() first. They then call
mtk_wed_wdma_rx_ring_setup() or mtk_wed_wdma_tx_ring_setup(). If the
wdma step fails, they return -ENOMEM before MTK_WED_RING_CONFIGURED
is set on the ring that was already allocated.

Once the free paths only call mtk_wed_free_ring() for rings with
MTK_WED_RING_CONFIGURED set, __mtk_wed_detach() skips those partially
set up rings. Their coherent DMA descriptor memory is then leaked.
Before this series, mtk_wed_free_ring() keyed off ring->desc, which
handled this case.

I see two options:

 - Keep relying on the ring->desc check in mtk_wed_free_ring() for
   freeing, so the flag gating is not needed in the free paths.
 - Free the just-allocated ring on the error path in the setup
   functions.

The right choice depends on what the flag gating is meant to protect
against, so could you explain the intent there?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261016-wedfix-v5-0-8b02e78fd34f%40gmail.com
Technical Details
Message-ID: <179249103985.3135.17834274932669029718@kernel.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-349187-linux-kernel-netdev=dewy.ru
References: <20261016-wedfix-v5-1-8b02e78fd34f@gmail.com>

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-349187-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v5 1/5] net: ethernet: mtk_wed: skip ring reset in
 wdma_tx_ring_setup for WED v3
Date: Tue, 20 Oct 2026 10:10:39 +0000
Organization: Usenet Network
Message-ID: <179249103985.3135.17834274932669029718@kernel.org>
References: <20261016-wedfix-v5-1-8b02e78fd34f@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="3829305"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:U5HOWk0QiIXm8YKVRXQm+FzKaeM= sha256:OewkMcuhYiBKQ1fIEsS+8ROjKloimGbKpLB76sdBPN8=
	sha1:PXDwxzeBTMSSEjmoV2UhC8bj4DY= sha256:jetvdK0T5sKpLJo3x/Gww/pgB0D4Z8+n54t6EC10SjA=
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 42F01110C89; Tue, 20 Oct 2026 13:18:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.728
X-Spam-Status: No, score=-3.728 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.329, 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, URIBL_BLOCKED=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 e65pC9uybVaz;
	Tue, 20 Oct 2026 13:18:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-349187-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 AFFE2110C22; Tue, 20 Oct 2026 13:18:04 +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 301CF3E6EA; Tue, 20 Oct 2026 10:11:12 +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=1792491048;
	b=RsOso5uY7RP8KazHj2j7feH25np3mfCIe99klL7pCRXi9h3bzNy5neOl9v+mAJ//ehbr
	 gxHZk74+GxZY4DyBp8xTesiuX9TR1ZgZooSJRlAjwtc3CeQ58Z1GExj/jks0hIwFkbXtG
	 KfU4JtJ75mahyVoEjxFlYrm2rWBuaQ+dqy66DVx/Q/LimBCRs2P/YtJKeJpX3M3oHKBoH
	 LEiREa7rO+XPHy+rClEY+jqmUK9N3RQF2d6HLSqrgZCaQCugz0RBcX2BsibNGN13TvKoS
	 3uuRnMY3lRxh7uH45DxS9wdM65pJv7RAQX44xCKQiDq0WQphcRuTMzB8XXtjGC6VxqA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792491048;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=5EL4xcpEAaTLBP9HyYnzoNI2lvu1UvL/iwtcQQL4HvU=;
	b=VFlrxU+nUWueY1k4r+iwWjGjcUBIzlPgKnfnuTav6xQKDaO3B7Ue87vzmXGphYdrxBUR
	 XUBtvbhGlOVwbk0uBYrzH8pvxO5l+/+LjG5Tf7LElcES1UqBzHetp04NWO+2Rhbkj9Cry
	 YB9/bsoLktwMLKXiDoEdTOUjktBI7EE4km3rVl6R55gmmQS16xidYMjdvEnD3/j8SeLKQ
	 PanaTDHDWUJbc0jfThfuJgJXII39OXLExEnJxJi5i9BmcHL74kl6gS5hIiTeUaHpq52sL
	 jL4xMR+pCDbFuiC0zU+EhmM0VORA/ioMyGo0vau4BYGokdVeYQxO9DROXIB5MZGufAw==
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=S9V7JYW3;
	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 BE63260A2624;
	Tue, 20 Oct 2026 10:10:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=S9V7JYW3
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=1792491041;
	b=IdyFE5+BnHONLckst9qco99lqlnm6Vk8sQIrO/DDmkA6X4ulM415VS9HiTVoBjfxywYk
	 hqzG7lE4tcmpXtu3JFzq0inUVLy6QdX75XtCVTEF4+pFImBTxZvKYd+V2KQuCUFtCfJ3h
	 wUWSI8F6bxvlSS+nNmwxl14oroihkgP40+kcQRumGl2aSa41rMe3nWahM8LaIb7uWx9+V
	 Nq54IhWbR/giAj0EsKR1+OHUVxJ2KD9j8IB053J1jpWM6cyZd6boWQDul5Wwm4YUYoykp
	 3rWMIBLD67EES2plSggLYDblzOdJNWnniXbx+8I720qrx8OdoV+Tn1jB95S+vk1Y1Nw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792491041;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=5EL4xcpEAaTLBP9HyYnzoNI2lvu1UvL/iwtcQQL4HvU=;
	b=va8AEBZ7a9ZrdiIp2V9jnm2n5XTc5SrLn/0Y/ud0edqmW4b5nIZqq2MwElh6nf752WXZ
	 EUs0B2h4lGbnWeZZ69CJEQiN4YBL0+WGK83ky12Ww4HNFgu/ysZJKsh1/s+ONtR9qIppk
	 rN2SZVSG0n0yiBV+rt3dyInkJ4gjCzUDcD32wChKvO22zwdMar3G/gMDyMzc67lsAuNiA
	 kVzIWJSWY+z6pC66yjng5Br6At2TN8vAgufT6tkNJHORxoGNFFVOZy3pmoVsAHWV9iBPf
	 SWH9u4uA7dcCvZV9MkFwynmozDsIbKfk1uvBklpYxQthMjYM5n2S3C85X8BFPO0QQxg==
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=S9V7JYW3;
	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 9A270606A31E;
	Tue, 20 Oct 2026 10:10:41 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 564461F000C4;
	Tue, 20 Oct 2026 10:10:40 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1792491041;
	bh=5EL4xcpEAaTLBP9HyYnzoNI2lvu1UvL/iwtcQQL4HvU=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=S9V7JYW3J5QXsgoaZUgvWdJVADjrvM9bjyxqXiHF+e/lbyGC4czDQuIr82jsBH3D7
	 4sdNyrht6TnJCO9hIxYM1u90t6bMX+gBGrouuvW8p+JqLeaSqr9TMImfss9w+2BOq4
	 btXMWQsGxlamT1Y8XCc5Eff5RjGgiKvOvgiELLsdr142LU+0EI6hRivdBzzhaS8jzw
	 pjSwQOroBeuiYbm3bNI/UwHXJyxXTc8fJDHiEl0w32dElxckkfrbANK0hpZZCNn3LZ
	 EnJFRGUQjmLjcRepZUTrid3mWgsVcGNnovKLEwtqFjlLQ2J7HnwfRGrtHQYQuo5iDe
	 fu6ArfV1nLdsg==
X-Cc: nbd@nbd.name, lorenzo@kernel.org, andrew+netdev@lunn.ch,
 davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
 sujuan.chen@mediatek.com, rex.lu@mediatek.com, netdev@vger.kernel.org,
 linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
 linux-mediatek@lists.infradead.org
X-In-Reply-To: <20261016-wedfix-v5-1-8b02e78fd34f@gmail.com>
X-sashiko-severity: High
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