mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maxime Chevallier <maxime.chevallier@bootlin.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, linux@armlinux.org.uk, hkallweit1@gmail.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	thomas.petazzoni@bootlin.com
Subject: Re: [PATCH net v2 1/3] net: phy: clean the sfp upstream if phy probing fails
Date: Fri, 5 Jun 2026 11:19:52 +0200	[thread overview]
Message-ID: <476ef2e0-b090-4a06-af3c-d2b97641cdc5@bootlin.com> (raw)
In-Reply-To: <20260605012403.3513979-1-kuba@kernel.org>



On 6/5/26 03:24, Jakub Kicinski wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
> ---
> net: phy: clean the sfp upstream if phy probing fails
> 
> This commit adds a call to sfp_bus_del_upstream() in the probe failure path
> to ensure the sfp-bus is not left with a dangling upstream field that could
> be used during subsequent SFP events.
> 
>> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
>> --- a/drivers/net/phy/phy_device.c
>> +++ b/drivers/net/phy/phy_device.c
> 
> [ ... ]
> 
>> @@ -3775,6 +3778,9 @@ static int phy_probe(struct device *dev)
>>  	return 0;
>>  
>>  out:
>> +	sfp_bus_del_upstream(phydev->sfp_bus);
>> +	phydev->sfp_bus = NULL;
>> +
> 
> [Severity: High]
> This is a pre-existing issue, but if a subsequent initialization step fails
> and we jump to the out label, should we be calling the specific PHY driver's
> remove callback?
> 
> If phydev->drv->probe() succeeds early in phy_probe(), but something like
> phy_setup_ports() or of_phy_leds() fails later, the execution jumps to this
> error path. Without calling phydev->drv->remove(phydev), any resources
> allocated by the driver are leaked.
> 
> Also, drivers like dp83640 register the phydev with external subsystems,
> such as adding it to shared lists like clock->phylist during their probe.
> Leaving dangling pointers to this unbound phydev in those subsystems could
> lead to use-after-free crashes later.

Good point too. I've sent a V3 already, so if V3 is accepted I'll send a
standalone patch for that, or include that in V4 should it be needed :)

Maxime

> 
>>  	if (!phydev->is_on_sfp_module)
>>  		phy_led_triggers_unregister(phydev);
>>


  reply	other threads:[~2026-06-05  9:20 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  8:40 [PATCH net v2 0/3] net: phy: some cleanups following phy_port SFP Maxime Chevallier
2026-06-01  8:40 ` [PATCH net v2 1/3] net: phy: clean the sfp upstream if phy probing fails Maxime Chevallier
2026-06-01  9:31   ` Nicolai Buchwitz
2026-06-05  1:24   ` Jakub Kicinski
2026-06-05  9:19     ` Maxime Chevallier [this message]
2026-06-01  8:40 ` [PATCH net v2 2/3] net: phy: remove phy ports upon probe failure Maxime Chevallier
2026-06-01  9:31   ` Nicolai Buchwitz
2026-06-04  8:02     ` Maxime Chevallier
2026-06-04  8:13       ` Nicolai Buchwitz
2026-06-04  2:27   ` Jakub Kicinski
2026-06-04  7:26     ` Maxime Chevallier
2026-06-01  8:40 ` [PATCH net v2 3/3] net: phy: don't try to setup PHY-driven SFP cages when using genphy Maxime Chevallier
2026-06-01  9:32   ` Nicolai Buchwitz
2026-06-04  2:27   ` Jakub Kicinski
2026-06-04  7:28     ` Maxime Chevallier

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=476ef2e0-b090-4a06-af3c-d2b97641cdc5@bootlin.com \
    --to=maxime.chevallier@bootlin.com \
    --cc=andrew+netdev@lunn.ch \
    --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=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=thomas.petazzoni@bootlin.com \
    /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

Powered by JetHome