🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26821

Re: [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure

#26821
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 07:51
128 lines
12430 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · 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).

- [Medium] Two changes in mt753x_setup() (drivers/net/dsa/mt7530.c) now
  power off the switch through sw_teardown while the GPIO controller is…

--

net: dsa: mt7530: disable regulators on mt753x_setup() failure

This patch sends every failure path in mt753x_setup() that runs after
sw_setup() to a shared error label. That label frees the mdio irq and
turns off the regulators. It also adds a per-variant sw_teardown()
callback, and for the MT7530 variants that callback calls
mt7530_disable_pwrs().

> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 1ae0ca2789690..32cf4a1ce2ace 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c

[ ... ]

> @@ -3232,11 +3240,11 @@ mt753x_setup(struct dsa_switch *ds)
>  
>  	ret = mt7530_setup_irq(priv);
>  	if (ret)
> -		return ret;
> +		goto err_disable_pwrs;
>  
>  	ret = mt7530_setup_mdio(priv);
>  	if (ret)
> -		goto err_disable_pwrs;
> +		goto err_disable_pwrs;

[Severity: Medium]
Can these two new error paths leave the GPIO controller registered for a
switch that has no power?

By the time mt753x_setup() reaches mt7530_setup_irq(), sw_setup() has
already run. The last thing mt7530_setup() does is register the gpiochip:

drivers/net/dsa/mt7530.c:mt7530_setup() {
    ...
#ifdef CONFIG_GPIOLIB
	if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
		ret = mt7530_setup_gpio(priv);
		if (ret)
			goto err_disable_pwrs;
	}
    ...
}

mt7530_setup_gpio() uses devm_gpiochip_add_data(). The gpiochip is
therefore only removed when the switch device's devres unwinds.
mt7530_teardown() does not remove it.

On the mt7530_setup_mdio() failure path, the regmap IRQ chip registered
by devm_regmap_add_irq_chip_fwnode() in mt7530_setup_irq() is also still
live, together with its threaded handler.

mt753x_setup()
  sw_setup() == mt7530_setup()
    mt7530_setup_gpio()
      devm_gpiochip_add_data()
  mt7530_setup_irq() fails (for example -EPROBE_DEFER from of_irq_get())
  goto err_disable_pwrs
    mt7530_teardown()
      mt7530_disable_pwrs()
        regulator_disable(core_pwr / io_pwr)

The earlier patch in this series, "net: dsa: mt7530: register the GPIO
controller last in setup", moved GPIO registration to the end of
mt7530_setup(). The goal was that the controller would not stay
registered across a failed setup that turns off the regulators. Doesn't
this patch add new failure points after that registration? One of them
is the -EPROBE_DEFER case the commit message calls common.

In a single-switch tree this state only lasts until the failed probe's
devres unwinds.

In a multi-switch tree, dsa_tree_setup() runs from whichever member
probes last. An MT7530 whose own probe already returned 0 would then keep
its devm gpiochip, and possibly its regmap-irq handler, registered while
its core and io rails are off. Any GPIO get/set/direction call would then
do regmap accesses on an unpowered chip.

Before this patch, these paths left the rails on. Only ID_MT7530 is
affected, because mt7530_disable_pwrs() returns early for other ids.

The commit message describes sw_teardown() as "symmetric with
sw_setup()". mt7530_teardown() only undoes the regulator enable, though,
not the gpiochip that sw_setup() registers. Would it make sense either to
unregister the gpiochip (and the regmap irq chip) before cutting power
here, or to keep the regulators on for these paths until devres cleanup
runs?

>  
>  	/* Initialise the PCS devices */
>  	for (i = 0; i < priv->ds->num_ports; i++) {

[ ... ]

> +	return 0;
> +
> +err_free_irq:
> +	if (priv->irq_domain)
> +		mt7530_free_mdio_irq(priv);
> +err_disable_pwrs:
> +	if (priv->info->sw_teardown)
> +		priv->info->sw_teardown(ds);
> +
>  	return ret;
>  }

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179628050300.1224.11499384961750115678%40mail.zgclab.edu.cn
Technical Details
Message-ID: <179637066398.3146.16717058703088608275@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377173-linux-kernel-netdev=dewy.ru
References: <179628050300.1224.2090604648819997374@mail.zgclab.edu.cn>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377173-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v2 5/5] net: dsa: mt7530: disable regulators on
 mt753x_setup() failure
Date: Fri, 04 Dec 2026 07:51:03 +0000
Organization: Usenet Network
Message-ID: <179637066398.3146.16717058703088608275@kernel.org>
References: <179628050300.1224.2090604648819997374@mail.zgclab.edu.cn>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2708745"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:wmkyNbTPDkGhiWOz4cFRe4xI9dc= sha256:RtnG6xYu8aN6pIIekoGBc6djJdHmrVAEROExw8U/d38=
	sha1:Qwerxt5gi+rIPf+WmWzMtxdVzzQ= sha256:gMI6W6RIouTWKyJPxcmVKpcMvrLsweU9U84WRxYIH88=
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 D0D51117B59; Fri,  4 Dec 2026 10:51:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.24, 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 0DQ-y2K_iZnH;
	Fri,  4 Dec 2026 10:51:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377173-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 A5EC7117B46; Fri,  4 Dec 2026 10:51:16 +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 8C42625E77; Fri,  4 Dec 2026 07:51:07 +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=1796370666;
	b=SahSAddXCahqSL1LYk5BtIG6usXYHn1pKc7vLaaAoEwAheQ+kr11w9BwSkUT6o1sR4vz
	 HcjUOLRgOlrGB1lIAxbL1Dr39Ya74AOMbJRW6jDY9alg+6GD2L0dZ4ZvQTxPV6arQi2XY
	 A1rKmyb5KmXCigHdBKBx4sSVtH749YG1xN/mdNElVpOoEAWNGJkHgWR5lYpDe8ysktITd
	 5SEgwsnck5ra+qllC0+uVZfSte9RqkLFkrwCmlkBXFsKMNavbjVtyh+rxTEqVW/13GUUJ
	 ebWMkfinG6DhPvdZz/D5uQfmPDuwpMbUsVGQWZMHPKZScsC6N144e/2zrsiS2XXHsmg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796370666;
	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=uYD23LsOI7Rlnq0noFIWKyU9zh02NlqM1CYGJeQBuaw=;
	b=m1LyZoEp/s55ua6RfKtA/QYsNJqOJDscHcw9vSIQJZ2JnuCrTKRudxE/n6oCYpVWl535
	 X3Baj3HKQZriSY70UytQb7Eszm7YZ/N21LpPBuJRrTxM2FN6PyEWOfdjDa4TtCStCasZN
	 Prj4nDM+2Q370mnpNcJ2McUOjmzGsL92nJ0pY1zJVgKK2MjuZP65sPJQFaasCBXINctKR
	 U5CPpAdFMaxSlotUa/JkGQ/wc14ktF8omu5p7tmfTKwsKlRmG6mmasdUvv1tyxTYMOYXS
	 J1MN/3qj46pZe0ytgQbB5mr1c1iVGJd4gLgj3chYsQ4Fcy00hAi5iP7/ermncv1sczQ==
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=YnPfeSdO;
	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 59067606A692;
	Fri,  4 Dec 2026 07:51:06 +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=YnPfeSdO
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=1796370665;
	b=zbpNXr/HU1Frd8YI9iFqnlb5ddKjFZSwnaxUzwKd/CCmFXiVh/SAFHgVyB1J8Pw67vUC
	 PYJnro3nxR8Xdxsuc7wMG0AwUGcpZPHXaE0vEPD0ZEVnYyKpkL7vRq+hm3oKjx5TMTQZt
	 q6PT1Hsxv8yNfeBgdoNMSxDo/azEXku80HvLOQFSmuMqNY8i84RbyfLDWbCRUR5JCbTtr
	 iIZKlp3HYc0UwefRcufG/6069+ZVXsMjYteWs04qq/Xp4cReAYE887GW04vgJ78YxY6u2
	 Mqc7NL44Sok6o5pgqcLTfHF3f7UOo4vwYy17Kn9Jx/S0fUdNjXEEqrI6XmZjx9O0KAw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796370665;
	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=uYD23LsOI7Rlnq0noFIWKyU9zh02NlqM1CYGJeQBuaw=;
	b=TgG6ULVDSVvkOMjDJEbKtIjQMCD8nBN6FVzy8N/3eLh5Mzw1rwsLAL8cW9tZpEvhcVNm
	 /S6uwXEnqacSOiCo52A0ko49ohiqFF9c2LZhDd6jSe8DGKj6uU0dpm6HrjUQzGGn1MyLK
	 WTdvzIZI9nUeUdgGbaL3AsWgFCQELHKddQibZaVPEIU3ZrV2inw/4er9/e/4CmdDqckaF
	 kqOZRoHOLyMqvEQtz9RsjNGRc6VKtozJUNEQt2h3TkkCKKfCiUSEtyp3/AdFVRSRoqVKb
	 lalwbazb64Vz6DnDHyF38c+9mbRy1DvphIG8C4WhJX8aorRt+UkGaFKcg7XTdkdJxvg==
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=YnPfeSdO;
	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 7B1AE606A336;
	Fri,  4 Dec 2026 07:51:05 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6531E1F0092C;
	Fri,  4 Dec 2026 07:51:04 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796370665;
	bh=uYD23LsOI7Rlnq0noFIWKyU9zh02NlqM1CYGJeQBuaw=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=YnPfeSdOHihndzBw0/dt/rMITcGDIx7VHCmZn9DV8EJ5i9GXO4U1+vORzCXbxaORW
	 N5OYlQVGZko/w0lFd7SuZ4GEgSTfn5/Qkotkty6EcK/zM+T/lAJvTP5gWxQ9kTvBq6
	 ZIz6UnG4xZnGDWScmyAbotGNhugXmAzfxAjIxnh8lOaTseYXsxKbQAlcaJDFhGlL33
	 4dQ+xGd4BMICsWCFalqDws/u/CySE71g1luGuyN5SrVXR7VWTPGIHhZqGdpgN0lVAT
	 mD/NhQOeQ5NVq64WYW81n/Kc6++4jEk3iN9y3EBd+bFoiQvYkYQVuCdcoNuhqC4Ijk
	 HHeX7C+ZbhwHQ==
X-Cc: chester.a.unal@arinc9.com, daniel@makrotopia.org, andrew@lunn.ch,
 olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
 pabeni@redhat.com, matthias.bgg@gmail.com,
 angelogioacchino.delregno@collabora.com, netdev@vger.kernel.org,
 linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <179628050300.1224.2090604648819997374@mail.zgclab.edu.cn>
X-sashiko-severity: Medium
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