diff mbox series

[v2] net: sh_eth: fix a missing check of of_get_phy_mode

Message ID 20190312063026.15083-1-kjlu@umn.edu (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series [v2] net: sh_eth: fix a missing check of of_get_phy_mode | expand

Commit Message

Kangjie Lu March 12, 2019, 6:30 a.m. UTC
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.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
 drivers/net/ethernet/renesas/sh_eth.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Sergei Shtylyov March 12, 2019, 7:31 a.m. UTC | #1
Hello!

On 12.03.2019 9:30, Kangjie Lu wrote:

> 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.
> 
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
>   drivers/net/ethernet/renesas/sh_eth.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
> index 239eeafe1b2d..e33af371b169 100644
> --- a/drivers/net/ethernet/renesas/sh_eth.c
> +++ b/drivers/net/ethernet/renesas/sh_eth.c
> @@ -3181,14 +3181,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);
> -	if (pdata->phy_interface < 0)

    Please generate your patch against the pristine net.git, not atop
of your previous version.

> +	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)
> 

MBR, Sergei
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 239eeafe1b2d..e33af371b169 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -3181,14 +3181,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);
-	if (pdata->phy_interface < 0)
+	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)