linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode
@ 2019-03-11  7:49 Kangjie Lu
  2019-03-11 10:29 ` Sergei Shtylyov
  2019-03-11 10:59 ` [PATCH v2] net: renesas: " Geert Uytterhoeven
  0 siblings, 2 replies; 12+ messages in thread
From: Kangjie Lu @ 2019-03-11  7:49 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Sergei Shtylyov, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Simon Horman, Chris Brandt, netdev,
	linux-renesas-soc, linux-kernel

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

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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode
  2019-03-11  7:49 [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode Kangjie Lu
@ 2019-03-11 10:29 ` Sergei Shtylyov
  2019-03-11 17:52   ` David Miller
  2019-03-11 10:59 ` [PATCH v2] net: renesas: " Geert Uytterhoeven
  1 sibling, 1 reply; 12+ messages in thread
From: Sergei Shtylyov @ 2019-03-11 10:29 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Simon Horman, Chris Brandt, netdev,
	linux-renesas-soc, linux-kernel

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode
  2019-03-11  7:49 [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode Kangjie Lu
  2019-03-11 10:29 ` Sergei Shtylyov
@ 2019-03-11 10:59 ` Geert Uytterhoeven
  2019-03-11 14:18   ` Sergei Shtylyov
  1 sibling, 1 reply; 12+ messages in thread
From: Geert Uytterhoeven @ 2019-03-11 10:59 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, Sergei Shtylyov, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Simon Horman, Chris Brandt, netdev,
	Linux-Renesas, Linux Kernel Mailing List

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

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode
  2019-03-11 10:59 ` [PATCH v2] net: renesas: " Geert Uytterhoeven
@ 2019-03-11 14:18   ` Sergei Shtylyov
  0 siblings, 0 replies; 12+ messages in thread
From: Sergei Shtylyov @ 2019-03-11 14:18 UTC (permalink / raw)
  To: Geert Uytterhoeven, Kangjie Lu
  Cc: pakki001, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Simon Horman, Chris Brandt, netdev,
	Linux-Renesas, Linux Kernel Mailing List

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode
  2019-03-11 10:29 ` Sergei Shtylyov
@ 2019-03-11 17:52   ` David Miller
  2019-03-11 17:55     ` Sergei Shtylyov
  0 siblings, 1 reply; 12+ messages in thread
From: David Miller @ 2019-03-11 17:52 UTC (permalink / raw)
  To: sergei.shtylyov
  Cc: kjlu, pakki001, vladimir_zapolskiy, geert+renesas, horms+renesas,
	chris.brandt, netdev, linux-renesas-soc, linux-kernel

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.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode
  2019-03-11 17:52   ` David Miller
@ 2019-03-11 17:55     ` Sergei Shtylyov
  2019-03-12  6:30       ` [PATCH v2] net: sh_eth: " Kangjie Lu
  0 siblings, 1 reply; 12+ messages in thread
From: Sergei Shtylyov @ 2019-03-11 17:55 UTC (permalink / raw)
  To: David Miller
  Cc: kjlu, pakki001, vladimir_zapolskiy, geert+renesas, horms+renesas,
	chris.brandt, netdev, linux-renesas-soc, linux-kernel

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v2] net: sh_eth: fix a missing check of of_get_phy_mode
  2019-03-11 17:55     ` Sergei Shtylyov
@ 2019-03-12  6:30       ` Kangjie Lu
  2019-03-12  7:31         ` Sergei Shtylyov
  0 siblings, 1 reply; 12+ messages in thread
From: Kangjie Lu @ 2019-03-12  6:30 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Sergei Shtylyov, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Chris Brandt, netdev, linux-renesas-soc,
	linux-kernel

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


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] net: sh_eth: fix a missing check of of_get_phy_mode
  2019-03-12  6:30       ` [PATCH v2] net: sh_eth: " Kangjie Lu
@ 2019-03-12  7:31         ` Sergei Shtylyov
  2019-03-12  7:43           ` [PATCH v3] " Kangjie Lu
  0 siblings, 1 reply; 12+ messages in thread
From: Sergei Shtylyov @ 2019-03-12  7:31 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Chris Brandt, netdev, linux-renesas-soc,
	linux-kernel

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH v3] net: sh_eth: fix a missing check of of_get_phy_mode
  2019-03-12  7:31         ` Sergei Shtylyov
@ 2019-03-12  7:43           ` Kangjie Lu
  2019-03-12  7:50             ` Sergei Shtylyov
                               ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Kangjie Lu @ 2019-03-12  7:43 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, Sergei Shtylyov, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Vladimir Barinov, Chris Brandt, netdev,
	linux-renesas-soc, linux-kernel

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, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 339b2eae2100..e33af371b169 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -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)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] net: sh_eth: fix a missing check of of_get_phy_mode
  2019-03-12  7:43           ` [PATCH v3] " Kangjie Lu
@ 2019-03-12  7:50             ` Sergei Shtylyov
  2019-03-12  8:18             ` Geert Uytterhoeven
  2019-03-12 21:51             ` David Miller
  2 siblings, 0 replies; 12+ messages in thread
From: Sergei Shtylyov @ 2019-03-12  7:50 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Vladimir Barinov, Chris Brandt, netdev,
	linux-renesas-soc, linux-kernel

On 12.03.2019 10:43, 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>

Fixes: b356e978e92f ("sh_eth: add device tree support")
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

> ---

    It's a good practice to describe the changes between the patch versions here.

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] net: sh_eth: fix a missing check of of_get_phy_mode
  2019-03-12  7:43           ` [PATCH v3] " Kangjie Lu
  2019-03-12  7:50             ` Sergei Shtylyov
@ 2019-03-12  8:18             ` Geert Uytterhoeven
  2019-03-12 21:51             ` David Miller
  2 siblings, 0 replies; 12+ messages in thread
From: Geert Uytterhoeven @ 2019-03-12  8:18 UTC (permalink / raw)
  To: Kangjie Lu
  Cc: pakki001, Sergei Shtylyov, David S. Miller, Vladimir Zapolskiy,
	Geert Uytterhoeven, Vladimir Barinov, Chris Brandt, netdev,
	Linux-Renesas, Linux Kernel Mailing List

Hi Kangjie,

On Tue, Mar 12, 2019 at 8:43 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>

Thanks for the update!

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v3] net: sh_eth: fix a missing check of of_get_phy_mode
  2019-03-12  7:43           ` [PATCH v3] " Kangjie Lu
  2019-03-12  7:50             ` Sergei Shtylyov
  2019-03-12  8:18             ` Geert Uytterhoeven
@ 2019-03-12 21:51             ` David Miller
  2 siblings, 0 replies; 12+ messages in thread
From: David Miller @ 2019-03-12 21:51 UTC (permalink / raw)
  To: kjlu
  Cc: pakki001, sergei.shtylyov, vladimir_zapolskiy, geert+renesas,
	vladimir.barinov, chris.brandt, netdev, linux-renesas-soc,
	linux-kernel

From: Kangjie Lu <kjlu@umn.edu>
Date: Tue, 12 Mar 2019 02:43:18 -0500

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

Applied with Fixes: tag added.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-03-12 21:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-11  7:49 [PATCH v2] net: renesas: fix a missing check of of_get_phy_mode Kangjie Lu
2019-03-11 10:29 ` Sergei Shtylyov
2019-03-11 17:52   ` David Miller
2019-03-11 17:55     ` Sergei Shtylyov
2019-03-12  6:30       ` [PATCH v2] net: sh_eth: " Kangjie Lu
2019-03-12  7:31         ` Sergei Shtylyov
2019-03-12  7:43           ` [PATCH v3] " Kangjie Lu
2019-03-12  7:50             ` Sergei Shtylyov
2019-03-12  8:18             ` Geert Uytterhoeven
2019-03-12 21:51             ` David Miller
2019-03-11 10:59 ` [PATCH v2] net: renesas: " Geert Uytterhoeven
2019-03-11 14:18   ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).