net: renesas: fix a missing check of of_get_phy_mode
Subsystems (3)
PATCH v2 1/1 net: renesas: fix a missing check of of_get_phy_mode
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.
--- drivers/net/ethernet/renesas/sh_eth.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/renesas/sh_eth.c +2 -0
@@ -3187,6 +3187,8 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)return NULL ; pdata->phy_interface =of_get_phy_mode (np); +if (pdata->phy_interface <0 ) +return NULL ; mac_addr =of_get_mac_address (np);if (mac_addr)
Signature · 1 line
2.17.1
Hello!
Quoted 3 lines · Kangjie Lu
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.
Sorry, I overlooked this issue.
Quoted 1 line
Signed-off-by Kangjie Lu <[email protected]>
Quoted 3 lines
--- drivers/net/ethernet/renesas/sh_eth.c | 2 ++ 1 file changed, 2 insertions(+)
Why are you not fixing ravb_main.c as well? Especially as you have "renesas:"
in your subject, not "sh_eth:"? :-/
[...]
MBR, Sergei
David Miller
maintainerFrom: Sergei Shtylyov <[email protected]>
Date: Mon, 11 Mar 2019 13:29:10 +0300
Quoted 15 lines
Hello!
Quoted 3 lines · Kangjie Lu
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Sorry, I overlooked this issue.
Quoted 1 line
Signed-off-by Kangjie Lu <[email protected]>Fixes b356e978e92f ("sh_eth: add device tree support")Reviewed-by Sergei Shtylyov <[email protected]>
Quoted 6 lines
Quoted 3 lines
--- drivers/net/ethernet/renesas/sh_eth.c | 2 ++ 1 file changed, 2 insertions(+)Why are you not fixing
ravb_main.cas well? Especially as you have "renesas:"
in your subject, not "sh_eth:"? :-/
Kangjie please fix the subject line and incorporate Sergei's Fixes and Reviewed-by tags.
Thanks.
Quoted 15 lines · David Miller
Quoted 15 lines
Quoted 3 lines
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Sorry, I overlooked this issue.
Quoted 1 line
Signed-off-by Kangjie Lu <[email protected]>Fixes b356e978e92f ("sh_eth: add device tree support")Reviewed-by Sergei Shtylyov <[email protected]>Quoted 3 lines
--- drivers/net/ethernet/renesas/sh_eth.c | 2 ++ 1 file changed, 2 insertions(+)
Quoted 5 lines
Quoted 2 lines
Why are you not fixing
ravb_main.cas well? Especially as you have "renesas:"
in your subject, not "sh_eth:"? :-/Kangjie please fix the subject line and incorporate Sergei's Fixes and Reviewed-by tags.
For the record, this patch was a nop, I have to NAK it. Kangjie, please address
Geert's feedback, thanks.
Quoted 1 line
Thanks.
MBR, Sergei
PATCH v2 1/1 net: sh_eth: fix a missing check of of_get_phy_mode
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.
--- drivers/net/ethernet/renesas/sh_eth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/renesas/sh_eth.c +4 -2
@@ -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)
Signature · 1 line
2.17.1
Re: [PATCH v2] net: sh_eth: fix a missing check of of_get_phy_mode
Hello!
Quoted 15 lines · Kangjie Lu
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Signed-off-by Kangjie Lu <[email protected]>--- drivers/net/ethernet/renesas/sh_eth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/ethernet/renesas/sh_eth.c +0
-0@@ -3181,14 +3181,16 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)struct device_node *np = dev->of_node;
drivers/net/ethernet/renesas/sh_eth.c static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) · line 3190
Quoted 10 lines
drivers/net/ethernet/renesas/sh_eth.c +1
-2struct 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.
drivers/net/ethernet/renesas/sh_eth.c static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) · line 3196
Quoted 8 lines
drivers/net/ethernet/renesas/sh_eth.c +3
-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)
MBR, Sergei
PATCH v3 1/1 net: sh_eth: fix a missing check of of_get_phy_mode
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.
--- drivers/net/ethernet/renesas/sh_eth.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/renesas/sh_eth.c +5 -1
@@ -3181,12 +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); + 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)
Signature · 1 line
2.17.1
Re: [PATCH v3] net: sh_eth: fix a missing check of of_get_phy_mode
Quoted 5 lines · Kangjie Lu
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Signed-off-by Kangjie Lu <[email protected]>
Quoted 1 line
---
It's a good practice to describe the changes between the patch versions here.
[...]
MBR, Sergei
Re: [PATCH v3] net: sh_eth: fix a missing check of of_get_phy_mode
In reply to Kangjie LuHi Kangjie,
Quoted 5 lines · Kangjie Lu
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Signed-off-by Kangjie Lu <[email protected]>
Thanks for the update!
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
David Miller
maintainerRe: [PATCH v3] net: sh_eth: fix a missing check of of_get_phy_mode
In reply to Kangjie LuFrom: Kangjie Lu <[email protected]>
Date: Tue, 12 Mar 2019 02:43:18 -0500
Quoted 5 lines
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Signed-off-by Kangjie Lu <[email protected]>
Applied with Fixes: tag added.
Hi Kangjie,
Quoted 9 lines · Kangjie Lu
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Signed-off-by Kangjie Lu <[email protected]>
drivers/net/ethernet/renesas/sh_eth.c static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) · line 3191
Quoted 5 lines
drivers/net/ethernet/renesas/sh_eth.c +2
-0@@ -3187,6 +3187,8 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)return NULL ; pdata->phy_interface =of_get_phy_mode (np); +if (pdata->phy_interface <0 ) +return NULL ;
sh_eth_plat_data.phy_interface has type phy_interface_t. This is an enum containing only positive values, hence it is unsigned. So the condition can never be true.
of_get_phy_mode() returns int, as it has to indicate errors by returning negative error codes. Hence please use an intermediate of type int:
int ret;
...
ret = of_get_phy_mode(np);
if (ret < 0)
return NULL;
pdata->phy_interface = ret;drivers/net/ethernet/renesas/sh_eth.c static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) · line 3194
Quoted 3 lines
drivers/net/ethernet/renesas/sh_eth.c +0
-0mac_addr =of_get_mac_address (np);if (mac_addr)
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 11 lines · Geert Uytterhoeven
Quoted 11 lines
of_get_phy_modemay fail and return a negative error code; the fix checks the return value ofof_get_phy_modeand returns NULL of it fails.Signed-off-by Kangjie Lu <[email protected]>drivers/net/ethernet/renesas/sh_eth.c +0
-0@@ -3187,6 +3187,8 @@ static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev)return NULL ;
Quoted 7 lines
drivers/net/ethernet/renesas/sh_eth.c static struct sh_eth_plat_data *sh_eth_parse_dt(struct device *dev) · line 3191
Quoted 3 lines
drivers/net/ethernet/renesas/sh_eth.c +2
-0pdata->phy_interface =of_get_phy_mode (np); +if (pdata->phy_interface <0 ) +return NULL ;sh_eth_plat_data.phy_interface has type
phy_interface_t. This is an enum containing only positive values, hence it is unsigned. So the condition can never be true.
Good catch, thank you!
My gcc doesn't warn but doesn't generate the code for the branch either...
[...]
Quoted 3 lines
Gr{oetje,eeting}s,
Geert
MBR, Sergei