]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
drivers: phy: Set phy->dev to NULL when generic_phy_get_by_index() fails
authorPatrice Chotard <patrice.chotard@st.com>
Tue, 18 Jul 2017 09:38:42 +0000 (11:38 +0200)
committerMarek Vasut <marex@denx.de>
Fri, 28 Jul 2017 21:34:04 +0000 (23:34 +0200)
phy->dev need to be set to NULL in case of generic_phy_get_by_index()
fails. Then phy->dev can be used to check if the phy is valid

Reported-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/phy/phy-uclass.c

index d8b8d58e44f30d8f1cbc4423f7542f343a5c6ff2..68e518fc79008be1bbeff09cf71a6750447ee619 100644 (file)
@@ -45,6 +45,7 @@ int generic_phy_get_by_index(struct udevice *dev, int index,
        debug("%s(dev=%p, index=%d, phy=%p)\n", __func__, dev, index, phy);
 
        assert(phy);
+       phy->dev = NULL;
        ret = dev_read_phandle_with_args(dev, "phys", "#phy-cells", 0, index,
                                         &args);
        if (ret) {