]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: phy: possible NULL dereference in fixed_phy_create()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Mon, 11 Jul 2022 17:40:13 +0000 (19:40 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 8 Aug 2022 15:37:57 +0000 (11:37 -0400)
We check if phydev is NULL. Only but if it is non-NULL we set one
component of phydev. But even if it is NULL we set another. We should not
dereference NULL in either case.

Fixes: e24b58f5ed4f ("net: phy: don't require PHY interface mode during PHY creation")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Marek BehĂșn <kabel@kernel.org>
drivers/net/phy/phy.c

index e6e175551880fa351c1fcf6fe63bd55d4dc04de9..0350afdd1b68bf28c67ed262aa37c07cb316b157 100644 (file)
@@ -984,10 +984,10 @@ struct phy_device *fixed_phy_create(ofnode node)
        }
 
        phydev = phy_device_create(NULL, 0, PHY_FIXED_ID, false);
-       if (phydev)
+       if (phydev) {
                phydev->node = subnode;
-
-       phydev->interface = ofnode_read_phy_mode(node);
+               phydev->interface = ofnode_read_phy_mode(node);
+       }
 
        return phydev;
 }