Skip to contentSkip to conversation

net: phy: qcom: at803x: fix kernel panic with at8031_probe

PATCH Applied Christian Marangi 3 participants 3 messages Mar 25, 2024 – Mar 28, 2024

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: phy: qcom: at803x: fix kernel panic with at8031_probe

On reworking and splitting the at803x driver, in splitting function of at803x PHYs it was added a NULL dereference bug where priv is referenced before it's actually allocated and then is tried to write to for the is_1000basex and is_fiber variables in the case of at8031, writing on the wrong address.

Fix this by correctly setting priv local variable only after at803x_probe is called and actually allocates priv in the phydev struct.

Fixes 25d2ba94005f ("net: phy: at803x: move specific at8031 probe mode check to dedicated probe")
---
 drivers/net/phy/qcom/at803x.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/phy/qcom/at803x.c +3 -1
index 4717c59d51d0..e79657f76bea 100644
@@ -797,7 +797,7 @@ static int at8031_parse_dt(struct phy_device *phydev)
 
 static int at8031_probe(struct phy_device *phydev)
 {
-	struct at803x_priv *priv = phydev->priv;
+	struct at803x_priv *priv;
 	int mode_cfg;
 	int ccr;
 	int ret;
@@ -806,6 +806,8 @@ static int at8031_probe(struct phy_device *phydev)
 	if (ret)
 		return ret;
 
+	priv = phydev->priv;
+
 	/* Only supported on AR8031/AR8033, the AR8030/AR8035 use strapping
 	 * options.
 	 */
Signature · 1 line
2.43.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Christian Marangi

On reworking and splitting the at803x driver, in splitting function of at803x PHYs it was added a NULL dereference bug where priv is referenced before it's actually allocated and then is tried to write to for the is_1000basex and is_fiber variables in the case of at8031, writing on the wrong address.

Quoted 7 lines

Fix this by correctly setting priv local variable only after at803x_probe is called and actually allocates priv in the phydev struct.

Fixes 25d2ba94005f ("net: phy: at803x: move specific at8031 probe mode check to dedicated probe")

Andrew

#2 lore raw
In reply to Christian Marangi
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Mon, 25 Mar 2024 20:06:19 +0100 you wrote:

On reworking and splitting the at803x driver, in splitting function of at803x PHYs it was added a NULL dereference bug where priv is referenced before it's actually allocated and then is tried to write to for the is_1000basex and is_fiber variables in the case of at8031, writing on the wrong address.

Fix this by correctly setting priv local variable only after at803x_probe is called and actually allocates priv in the phydev struct.

[...]

Here is the summary with links:
- [net] net: phy: qcom: at803x: fix kernel panic with at8031_probe

    https://git.kernel.org/netdev/net/c/6a4aee277740

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html