Commit 63cc5414 authored by Kangjie Lu's avatar Kangjie Lu Committed by Kleber Sacilotto de Souza

net: sh_eth: fix a missing check of of_get_phy_mode

BugLink: https://bugs.launchpad.net/bugs/1864773

[ Upstream commit 035a14e7 ]

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 NULL of it fails.

Fixes: b356e978 ("sh_eth: add device tree support")
Signed-off-by: default avatarKangjie Lu <kjlu@umn.edu>
Reviewed-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Tested-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarKhalid Elmously <khalid.elmously@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 928b9496
......@@ -3040,12 +3040,16 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
struct device_node *np = dev->of_node;
struct sh_eth_plat_data *pdata;
const char *mac_addr;
int ret;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
pdata->phy_interface = of_get_phy_mode(np);
ret = of_get_phy_mode(np);
if (ret < 0)
return NULL;
pdata->phy_interface = ret;
mac_addr = of_get_mac_address(np);
if (mac_addr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment