Netdev List
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Xuanqiang Luo <xuanqiang.luo@linux.dev>,
	netdev@vger.kernel.org, kuba@kernel.org, andrew@lunn.ch
Cc: hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net,
	edumazet@google.com, pabeni@redhat.com, chleroy@kernel.org,
	linux-kernel@vger.kernel.org,
	Xuanqiang Luo <luoxuanqiang@kylinos.cn>
Subject: Re: [PATCH net v3 5/5] net: phy: propagate errors from default port setup
Date: Wed, 19 Aug 2026 11:27:50 +0200	[thread overview]
Message-ID: <9458a186-0f62-434d-9602-522500e9340c@bootlin.com> (raw)
In-Reply-To: <20260819060236.24665-6-xuanqiang.luo@linux.dev>

Hi,

On 8/19/26 08:02, Xuanqiang Luo wrote:
> From: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
> 
> phy_default_setup_single_port() ignores errors from phy_add_port() and
> always reports success. If a PHY driver attach_mdi_port() callback fails,
> the phy_port is leaked and PHY probing continues without the expected
> default port.
> 
> Destroy the port and return the error.
> 
> Fixes: 589e934d2735 ("net: phy: Introduce PHY ports representation")
> Signed-off-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com

Maxime

> ---
>  drivers/net/phy/phy_device.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 77318659ff985..22a5af92c620a 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -3458,6 +3458,7 @@ static int phy_default_setup_single_port(struct phy_device *phydev)
>  {
>  	struct phy_port *port = phy_port_alloc();
>  	unsigned long mode;
> +	int ret;
>  
>  	if (!port)
>  		return -ENOMEM;
> @@ -3484,9 +3485,11 @@ static int phy_default_setup_single_port(struct phy_device *phydev)
>  		port->pairs = max_t(int, port->pairs,
>  				    ethtool_linkmode_n_pairs(mode));
>  
> -	phy_add_port(phydev, port);
> +	ret = phy_add_port(phydev, port);
> +	if (ret)
> +		phy_port_destroy(port);
>  
> -	return 0;
> +	return ret;
>  }
>  
>  static int of_phy_ports(struct phy_device *phydev)


      reply	other threads:[~2026-08-19  9:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-19  6:02 [PATCH net v3 0/5] net: phy: fix cleanup after probe failure Xuanqiang Luo
2026-08-19  6:02 ` [PATCH net v3 1/5] net: phy: split phy_probe() error paths Xuanqiang Luo
2026-08-19  6:02 ` [PATCH net v3 2/5] net: phy: unregister SFP upstream before port cleanup Xuanqiang Luo
2026-08-19  6:02 ` [PATCH net v3 3/5] net: phy: set PHY_READY after LED setup Xuanqiang Luo
2026-08-19  6:02 ` [PATCH net v3 4/5] net: phy: call driver remove when core initialization fails Xuanqiang Luo
2026-08-19  6:02 ` [PATCH net v3 5/5] net: phy: propagate errors from default port setup Xuanqiang Luo
2026-08-19  9:27   ` Maxime Chevallier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9458a186-0f62-434d-9602-522500e9340c@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=andrew@lunn.ch \
    --cc=chleroy@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=luoxuanqiang@kylinos.cn \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=xuanqiang.luo@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox