Skip to content

Commit

Permalink
net: dwmac-sun8i: fix a missing check of of_get_phy_mode
Browse files Browse the repository at this point in the history
of_get_phy_mode may fail and return a negative error code;
the fix checks the return value of of_get_phy_mode and
returns -EINVAL of it fails.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kangjie Lu authored and David S. Miller committed Mar 12, 2019
1 parent 035a14e commit 4ec850e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,10 @@ static int sun8i_dwmac_probe(struct platform_device *pdev)
return ret;
}

plat_dat->interface = of_get_phy_mode(dev->of_node);
ret = of_get_phy_mode(dev->of_node);
if (ret < 0)
return -EINVAL;
plat_dat->interface = ret;

/* platform data specifying hardware features and callbacks.
* hardware features were copied from Allwinner drivers.
Expand Down

0 comments on commit 4ec850e

Please sign in to comment.