Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: phy: dp83848: check phy_read() return value in config_init()
@ 2026-09-02  6:58 Donggeun Yoo
  2026-09-02  8:10 ` Maxime Chevallier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Donggeun Yoo @ 2026-09-02  6:58 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Alvaro Gamez Machado
  Cc: Donggeun Yoo, netdev, linux-kernel

dp83848_config_init() reads BMCR to detect whether auto-negotiation is
enabled, but does not check the phy_read() return value. On an MDIO read
failure phy_read() returns a negative errno, which is then used directly
in a bitwise test; the auto-negotiation state is left undefined while
config_init() still reports success.

Check the return value and propagate the error.

Fixes: b718e8c8f4f5 ("net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620")
Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>
---
Only compile-tested; I do not have DP83848-family hardware.

 drivers/net/phy/dp83848.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
index d88b1999d596..e65651ac567a 100644
--- a/drivers/net/phy/dp83848.c
+++ b/drivers/net/phy/dp83848.c
@@ -117,6 +117,9 @@ static int dp83848_config_init(struct phy_device *phydev)
 	 * we check initial value of BMCR Auto negotiation enable bit
 	 */
 	val = phy_read(phydev, MII_BMCR);
+	if (val < 0)
+		return val;
+
 	if (!(val & BMCR_ANENABLE))
 		phydev->autoneg = AUTONEG_DISABLE;
 

base-commit: 70f3995830d3f1e79faa14eb0605914f778feca9
-- 
2.53.0


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

* Re: [PATCH net] net: phy: dp83848: check phy_read() return value in config_init()
  2026-09-02  6:58 [PATCH net] net: phy: dp83848: check phy_read() return value in config_init() Donggeun Yoo
@ 2026-09-02  8:10 ` Maxime Chevallier
  2026-09-02  8:18 ` Xuanqiang Luo
  2026-09-04  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Maxime Chevallier @ 2026-09-02  8:10 UTC (permalink / raw)
  To: Donggeun Yoo, Andrew Lunn, Heiner Kallweit, Russell King,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Alvaro Gamez Machado
  Cc: netdev, linux-kernel

Hi,

On 9/2/26 08:58, Donggeun Yoo wrote:
> dp83848_config_init() reads BMCR to detect whether auto-negotiation is
> enabled, but does not check the phy_read() return value. On an MDIO read
> failure phy_read() returns a negative errno, which is then used directly
> in a bitwise test; the auto-negotiation state is left undefined while
> config_init() still reports success.
> 
> Check the return value and propagate the error.
> 
> Fixes: b718e8c8f4f5 ("net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620")
> Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>

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

Maxime

> ---
> Only compile-tested; I do not have DP83848-family hardware.
> 
>  drivers/net/phy/dp83848.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c
> index d88b1999d596..e65651ac567a 100644
> --- a/drivers/net/phy/dp83848.c
> +++ b/drivers/net/phy/dp83848.c
> @@ -117,6 +117,9 @@ static int dp83848_config_init(struct phy_device *phydev)
>  	 * we check initial value of BMCR Auto negotiation enable bit
>  	 */
>  	val = phy_read(phydev, MII_BMCR);
> +	if (val < 0)
> +		return val;
> +
>  	if (!(val & BMCR_ANENABLE))
>  		phydev->autoneg = AUTONEG_DISABLE;
>  
> 
> base-commit: 70f3995830d3f1e79faa14eb0605914f778feca9


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

* Re: [PATCH net] net: phy: dp83848: check phy_read() return value in config_init()
  2026-09-02  6:58 [PATCH net] net: phy: dp83848: check phy_read() return value in config_init() Donggeun Yoo
  2026-09-02  8:10 ` Maxime Chevallier
@ 2026-09-02  8:18 ` Xuanqiang Luo
  2026-09-04  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Xuanqiang Luo @ 2026-09-02  8:18 UTC (permalink / raw)
  To: Donggeun Yoo
  Cc: netdev, linux-kernel, Andrew Lunn, Heiner Kallweit, Russell King,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Alvaro Gamez Machado


在 2026/9/2 14:58, Donggeun Yoo 写道:
> dp83848_config_init() reads BMCR to detect whether auto-negotiation is
> enabled, but does not check the phy_read() return value. On an MDIO read
> failure phy_read() returns a negative errno, which is then used directly
> in a bitwise test; the auto-negotiation state is left undefined while
> config_init() still reports success.
>
> Check the return value and propagate the error.
>
> Fixes: b718e8c8f4f5 ("net: phy: dp83822: use BMCR_ANENABLE instead of BMSR_ANEGCAPABLE for DP83620")
> Signed-off-by: Donggeun Yoo <donggeunyoo.kernel@gmail.com>

Reviewed-by: Xuanqiang Luo <luoxuanqiang@kylinos.cn>

Thanks,
Xuanqiang


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

* Re: [PATCH net] net: phy: dp83848: check phy_read() return value in config_init()
  2026-09-02  6:58 [PATCH net] net: phy: dp83848: check phy_read() return value in config_init() Donggeun Yoo
  2026-09-02  8:10 ` Maxime Chevallier
  2026-09-02  8:18 ` Xuanqiang Luo
@ 2026-09-04  0:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-04  0:50 UTC (permalink / raw)
  To: Donggeun Yoo
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	alvaro.gamez, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  2 Sep 2026 15:58:27 +0900 you wrote:
> dp83848_config_init() reads BMCR to detect whether auto-negotiation is
> enabled, but does not check the phy_read() return value. On an MDIO read
> failure phy_read() returns a negative errno, which is then used directly
> in a bitwise test; the auto-negotiation state is left undefined while
> config_init() still reports success.
> 
> Check the return value and propagate the error.
> 
> [...]

Here is the summary with links:
  - [net] net: phy: dp83848: check phy_read() return value in config_init()
    https://git.kernel.org/netdev/net-next/c/8c9190bfd18a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-09-04  0:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02  6:58 [PATCH net] net: phy: dp83848: check phy_read() return value in config_init() Donggeun Yoo
2026-09-02  8:10 ` Maxime Chevallier
2026-09-02  8:18 ` Xuanqiang Luo
2026-09-04  0:50 ` patchwork-bot+netdevbpf

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