mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v1] net: mv643xx_eth: Fix an error handling path in mv643xx_eth_probe()
@ 2025-09-22  8:08 Christophe JAILLET
  2025-09-22 12:53 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2025-09-22  8:08 UTC (permalink / raw)
  To: Sebastian Hesselbarth, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Lennert Buytenhek,
	Andy Fleming
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, netdev

If an error occurs after calling phy_connect_direct(), phy_disconnect()
should be called, as already done in the remove function.

Fixes: ed94493fb38a ("mv643xx_eth: convert to phylib")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative and compile tested only.
Review with care.
---
 drivers/net/ethernet/marvell/mv643xx_eth.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 0ab52c57c648..de6a683d7afc 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -3263,6 +3263,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
 	return 0;
 
 out:
+	if (dev->phydev)
+		phy_disconnect(dev->phydev);
 	if (!IS_ERR(mp->clk))
 		clk_disable_unprepare(mp->clk);
 	free_netdev(dev);
-- 
2.51.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v1] net: mv643xx_eth: Fix an error handling path in mv643xx_eth_probe()
  2025-09-22  8:08 [PATCH net v1] net: mv643xx_eth: Fix an error handling path in mv643xx_eth_probe() Christophe JAILLET
@ 2025-09-22 12:53 ` Andrew Lunn
  2025-09-22 15:34   ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2025-09-22 12:53 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Sebastian Hesselbarth, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Lennert Buytenhek,
	Andy Fleming, linux-kernel, kernel-janitors, netdev

On Mon, Sep 22, 2025 at 10:08:28AM +0200, Christophe JAILLET wrote:
> If an error occurs after calling phy_connect_direct(), phy_disconnect()
> should be called, as already done in the remove function.
> 
> Fixes: ed94493fb38a ("mv643xx_eth: convert to phylib")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> This patch is speculative and compile tested only.
> Review with care.
> ---
>  drivers/net/ethernet/marvell/mv643xx_eth.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
> index 0ab52c57c648..de6a683d7afc 100644
> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
> @@ -3263,6 +3263,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
>  	return 0;
>  
>  out:
> +	if (dev->phydev)
> +		phy_disconnect(dev->phydev);

This is correct, but it is a little bit less obviously correct than it
could be. Nothing in mv643xx_eth_probe sets dev->phydev. It happens
deep down in the call chain of of_phy_connect(). Just using:

	if (phydev)
		phy_disconnect(phydev);

would be more obvious for this probe function.

But since it is correct, Reviewed-by: Andrew Lunn <andrew@lunn.ch>
and i will leave you to decide if you want to change it.

    Andrew

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v1] net: mv643xx_eth: Fix an error handling path in mv643xx_eth_probe()
  2025-09-22 12:53 ` Andrew Lunn
@ 2025-09-22 15:34   ` Christophe JAILLET
  0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2025-09-22 15:34 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: Sebastian Hesselbarth, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Lennert Buytenhek,
	Andy Fleming, linux-kernel, kernel-janitors, netdev

Le 22/09/2025 à 14:53, Andrew Lunn a écrit :
> On Mon, Sep 22, 2025 at 10:08:28AM +0200, Christophe JAILLET wrote:
>> If an error occurs after calling phy_connect_direct(), phy_disconnect()
>> should be called, as already done in the remove function.
>>
>> Fixes: ed94493fb38a ("mv643xx_eth: convert to phylib")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>> This patch is speculative and compile tested only.
>> Review with care.
>> ---
>>   drivers/net/ethernet/marvell/mv643xx_eth.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
>> index 0ab52c57c648..de6a683d7afc 100644
>> --- a/drivers/net/ethernet/marvell/mv643xx_eth.c
>> +++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
>> @@ -3263,6 +3263,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
>>   	return 0;
>>   
>>   out:
>> +	if (dev->phydev)
>> +		phy_disconnect(dev->phydev);
> 
> This is correct, but it is a little bit less obviously correct than it
> could be. Nothing in mv643xx_eth_probe sets dev->phydev. It happens
> deep down in the call chain of of_phy_connect(). Just using:
> 
> 	if (phydev)
> 		phy_disconnect(phydev);
> 
> would be more obvious for this probe function.
> 
> But since it is correct, Reviewed-by: Andrew Lunn <andrew@lunn.ch>
> and i will leave you to decide if you want to change it.
> 
>      Andrew
> 
> 

In the (pd->phy_addr != MV643XX_ETH_PHY_NONE) case, phydev could be an 
error code.

So, we should do something like:
	if (!IS_ERR_OR_NULL(phydev))
		phy_disconnect(phydev);

Agree?

CJ




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-22 15:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-22  8:08 [PATCH net v1] net: mv643xx_eth: Fix an error handling path in mv643xx_eth_probe() Christophe JAILLET
2025-09-22 12:53 ` Andrew Lunn
2025-09-22 15:34   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®