Skip to content

Commit 6a4aee2

Browse files
AnsuelPaolo Abeni
authored andcommitted
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. Reported-by: William Wortel <[email protected]> Cc: <[email protected]> Fixes: 25d2ba9 ("net: phy: at803x: move specific at8031 probe mode check to dedicated probe") Signed-off-by: Christian Marangi <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 005e528 commit 6a4aee2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/phy/qcom/at803x.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ static int at8031_parse_dt(struct phy_device *phydev)
797797

798798
static int at8031_probe(struct phy_device *phydev)
799799
{
800-
struct at803x_priv *priv = phydev->priv;
800+
struct at803x_priv *priv;
801801
int mode_cfg;
802802
int ccr;
803803
int ret;
@@ -806,6 +806,8 @@ static int at8031_probe(struct phy_device *phydev)
806806
if (ret)
807807
return ret;
808808

809+
priv = phydev->priv;
810+
809811
/* Only supported on AR8031/AR8033, the AR8030/AR8035 use strapping
810812
* options.
811813
*/

0 commit comments

Comments
 (0)