Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
net: ethernet: ti: am65-cpsw: Handle -EPROBE_DEFER for Serdes PHY
Browse files Browse the repository at this point in the history
In the am65_cpsw_init_serdes_phy() function, the error handling for the
call to the devm_of_phy_get() function misses the case where the return
value of devm_of_phy_get() is ERR_PTR(-EPROBE_DEFER). Proceeding without
handling this case will result in a crash when the "phy" pointer with
this value is dereferenced by phy_init() in am65_cpsw_enable_phy().

Fix this by adding appropriate error handling code.

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Fixes: dab2b26 ("net: ethernet: ti: am65-cpsw: Add support for SERDES configuration")
Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
Reviewed-by: Roger Quadros <rogerq@kernel.org>
Link: https://lore.kernel.org/r/20230118112136.213061-1-s-vadapalli@ti.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Siddharth-Vadapalli-at-TI authored and kuba-moo committed Jan 20, 2023
1 parent a76e88c commit 854617f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/ethernet/ti/am65-cpsw-nuss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,8 @@ static int am65_cpsw_init_serdes_phy(struct device *dev, struct device_node *por
phy = devm_of_phy_get(dev, port_np, name);
if (PTR_ERR(phy) == -ENODEV)
return 0;
if (IS_ERR(phy))
return PTR_ERR(phy);

/* Serdes PHY exists. Store it. */
port->slave.serdes_phy = phy;
Expand Down

0 comments on commit 854617f

Please sign in to comment.