Message ID | 20190311074939.517-1-kjlu@umn.edu (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Geert Uytterhoeven |
Headers | show |
Series | [v2] net: renesas: fix a missing check of of_get_phy_mode | expand |
Hello! On 03/11/2019 10:49 AM, 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. Sorry, I overlooked this issue. > Signed-off-by: Kangjie Lu <kjlu@umn.edu> Fixes: b356e978e92f ("sh_eth: add device tree support") Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> > --- > 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
Hi Kangjie, On Mon, Mar 11, 2019 at 8:50 AM Kangjie Lu <kjlu@umn.edu> 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> > --- a/drivers/net/ethernet/renesas/sh_eth.c > +++ b/drivers/net/ethernet/renesas/sh_eth.c > @@ -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; > > mac_addr = of_get_mac_address(np); > if (mac_addr) Gr{oetje,eeting}s, Geert
On 03/11/2019 01:59 PM, Geert Uytterhoeven 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> > >> --- a/drivers/net/ethernet/renesas/sh_eth.c >> +++ b/drivers/net/ethernet/renesas/sh_eth.c >> @@ -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. Good catch, thank you! My gcc doesn't warn but doesn't generate the code for the branch either... [...] > Gr{oetje,eeting}s, > > Geert MBR, Sergei
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Date: Mon, 11 Mar 2019 13:29:10 +0300 > Hello! > > On 03/11/2019 10:49 AM, 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. > > Sorry, I overlooked this issue. > >> Signed-off-by: Kangjie Lu <kjlu@umn.edu> > > Fixes: b356e978e92f ("sh_eth: add device tree support") > Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> > >> --- >> 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:"? :-/ Kangjie please fix the subject line and incorporate Sergei's Fixes and Reviewed-by tags. Thanks.
On 03/11/2019 08:52 PM, David Miller 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. >> >> Sorry, I overlooked this issue. >> >>> Signed-off-by: Kangjie Lu <kjlu@umn.edu> >> >> Fixes: b356e978e92f ("sh_eth: add device tree support") >> Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> >> >>> --- >>> 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:"? :-/ > > 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. > Thanks. MBR, Sergei
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c index 339b2eae2100..239eeafe1b2d 100644 --- a/drivers/net/ethernet/renesas/sh_eth.c +++ b/drivers/net/ethernet/renesas/sh_eth.c @@ -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)
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 | 2 ++ 1 file changed, 2 insertions(+)