mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 10:57:46 +00:00
net: sh_eth: fix a missing check of of_get_phy_mode
[ Upstream commit035a14e71f
] 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:b356e978e9
("sh_eth: add device tree support") Signed-off-by: Kangjie Lu <kjlu@umn.edu> Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
3e259009f5
commit
013cfff98d
1 changed files with 5 additions and 1 deletions
|
@ -3133,12 +3133,16 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)
|
||||||
struct device_node *np = dev->of_node;
|
struct device_node *np = dev->of_node;
|
||||||
struct sh_eth_plat_data *pdata;
|
struct sh_eth_plat_data *pdata;
|
||||||
const char *mac_addr;
|
const char *mac_addr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return NULL;
|
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);
|
mac_addr = of_get_mac_address(np);
|
||||||
if (mac_addr)
|
if (mac_addr)
|
||||||
|
|
Loading…
Reference in a new issue