]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
net: sh_eth: fix a missing check of of_get_phy_mode
authorKangjie Lu <kjlu@umn.edu>
Tue, 12 Mar 2019 07:43:18 +0000 (02:43 -0500)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 14 Feb 2020 05:29:37 +0000 (00:29 -0500)
BugLink: https://bugs.launchpad.net/bugs/1863019
[ Upstream commit 035a14e71f27eefa50087963b94cbdb3580d08bf ]

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: b356e978e92f ("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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/renesas/sh_eth.c

index 22ea14505e8adca5a70ca779b1038dac292d3b0e..12f5667a8dc55265436c005ef09fd23afacf8dd7 100644 (file)
@@ -3057,12 +3057,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)