]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: phy: qcom: at803x: fix kernel panic with at8031_probe
authorChristian Marangi <ansuelsmth@gmail.com>
Mon, 25 Mar 2024 19:06:19 +0000 (20:06 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 28 Mar 2024 09:42:22 +0000 (10:42 +0100)
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 <wwortel@dorpstraat.com>
Cc: <stable@vger.kernel.org>
Fixes: 25d2ba94005f ("net: phy: at803x: move specific at8031 probe mode check to dedicated probe")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20240325190621.2665-1-ansuelsmth@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/phy/qcom/at803x.c

index 4717c59d51d042c205218ed32c779a836a86577b..e79657f76bea238ceb79c0b3c45c989b08f7592e 100644 (file)
@@ -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.
         */