lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240108123444.r3k4mhgii2yontc4@skbuf>
Date: Mon, 8 Jan 2024 14:34:44 +0200
From: Vladimir Oltean <olteanv@...il.com>
To: Arınç ÜNAL <arinc.unal@...nc9.com>
Cc: Simon Horman <horms@...nel.org>, Daniel Golle <daniel@...rotopia.org>,
	Landen Chao <Landen.Chao@...iatek.com>,
	DENG Qingfang <dqfext@...il.com>,
	Sean Wang <sean.wang@...iatek.com>, Andrew Lunn <andrew@...n.ch>,
	Florian Fainelli <f.fainelli@...il.com>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Matthias Brugger <matthias.bgg@...il.com>,
	AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>,
	David Bauer <mail@...id-bauer.net>, mithat.guner@...ont.com,
	erkin.bozoglu@...ont.com,
	Luiz Angelo Daros de Luca <luizluca@...il.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH net-next] net: dsa: mt7530: support OF-based registration
 of switch MDIO bus

On Mon, Jan 08, 2024 at 03:14:45PM +0300, Arınç ÜNAL wrote:
> I realised that I also miss these:
> 
> - run of_node_put(mnp) if bus = devm_mdiobus_alloc(dev) fails
> - don't run mt7530_free_mdio_irq if MDIO bus is described on OF
> 
> Please let me know if this addresses everything:
> 
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 391c4dbdff42..cf2ff7680c15 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -2146,24 +2146,40 @@ mt7530_free_irq_common(struct mt7530_priv *priv)
>  static void
>  mt7530_free_irq(struct mt7530_priv *priv)
>  {
> -	mt7530_free_mdio_irq(priv);
> +	struct device_node *mnp, *np = priv->dev->of_node;
> +
> +	mnp = of_get_child_by_name(np, "mdio");
> +	if (!mnp)
> +		mt7530_free_mdio_irq(priv);
> +	of_node_put(mnp);
> +
>  	mt7530_free_irq_common(priv);
>  }
>  static int
>  mt7530_setup_mdio(struct mt7530_priv *priv)
>  {
> +	struct device_node *mnp, *np = priv->dev->of_node;
>  	struct dsa_switch *ds = priv->ds;
>  	struct device *dev = priv->dev;
>  	struct mii_bus *bus;
>  	static int idx;
> -	int ret;
> +	int ret = 0;
> +
> +	mnp = of_get_child_by_name(np, "mdio");
> +
> +	if (mnp && !of_device_is_available(mnp))
> +		goto out;
>  	bus = devm_mdiobus_alloc(dev);
> -	if (!bus)
> -		return -ENOMEM;
> +	if (!bus) {
> +		ret = -ENOMEM;
> +		goto out;
> +	}
> +
> +	if (!mnp)
> +		ds->user_mii_bus = bus;
> -	ds->user_mii_bus = bus;
>  	bus->priv = priv;
>  	bus->name = KBUILD_MODNAME "-mii";
>  	snprintf(bus->id, MII_BUS_ID_SIZE, KBUILD_MODNAME "-%d", idx++);
> @@ -2174,16 +2190,18 @@ mt7530_setup_mdio(struct mt7530_priv *priv)
>  	bus->parent = dev;
>  	bus->phy_mask = ~ds->phys_mii_mask;
> -	if (priv->irq)
> +	if (priv->irq && !mnp)
>  		mt7530_setup_mdio_irq(priv);
> -	ret = devm_mdiobus_register(dev, bus);
> +	ret = devm_of_mdiobus_register(dev, bus, mnp);
>  	if (ret) {
>  		dev_err(dev, "failed to register MDIO bus: %d\n", ret);
> -		if (priv->irq)
> +		if (priv->irq && !mnp)
>  			mt7530_free_mdio_irq(priv);
>  	}
> +out:
> +	of_node_put(mnp);
>  	return ret;
>  }

Looks ok.

Please note that net-next has now closed. Sorry that I couldn't bring
myself to review more during the weekend and the holidays.
https://lore.kernel.org/netdev/20240107172221.733a7a44@kernel.org/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ