linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: stmmac: Fix signedness bug in stmmac_probe_config_dt()
@ 2020-08-18 14:39 YueHaibing
  2020-08-18 14:51 ` Andreas Schwab
  2020-08-18 15:15 ` [PATCH v2] " YueHaibing
  0 siblings, 2 replies; 6+ messages in thread
From: YueHaibing @ 2020-08-18 14:39 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, ajayg
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, YueHaibing

The "plat->phy_interface" variable is an enum and in this context GCC
will treat it as an unsigned int so the error handling is never
triggered.

Fixes: b9f0b2f634c0 ("net: stmmac: platform: fix probe for ACPI devices")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f32317fa75c8..b5b558b02e7d 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -413,7 +413,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 	}
 
 	plat->phy_interface = device_get_phy_mode(&pdev->dev);
-	if (plat->phy_interface < 0)
+	if ((int)plat->phy_interface < 0)
 		return ERR_PTR(plat->phy_interface);
 
 	plat->interface = stmmac_of_get_mac_mode(np);
-- 
2.17.1



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

* Re: [PATCH] net: stmmac: Fix signedness bug in stmmac_probe_config_dt()
  2020-08-18 14:39 [PATCH] net: stmmac: Fix signedness bug in stmmac_probe_config_dt() YueHaibing
@ 2020-08-18 14:51 ` Andreas Schwab
  2020-08-18 15:15   ` Yuehaibing
  2020-08-18 15:15 ` [PATCH v2] " YueHaibing
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2020-08-18 14:51 UTC (permalink / raw)
  To: YueHaibing
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, ajayg, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

On Aug 18 2020, YueHaibing wrote:

> The "plat->phy_interface" variable is an enum and in this context GCC
> will treat it as an unsigned int so the error handling is never
> triggered.
>
> Fixes: b9f0b2f634c0 ("net: stmmac: platform: fix probe for ACPI devices")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index f32317fa75c8..b5b558b02e7d 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -413,7 +413,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>  	}
>  
>  	plat->phy_interface = device_get_phy_mode(&pdev->dev);
> -	if (plat->phy_interface < 0)
> +	if ((int)plat->phy_interface < 0)
>  		return ERR_PTR(plat->phy_interface);

I don't think the conversion to long when passed to ERR_PTR will produce
a negative value either (if long is wider than unsigned int).

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

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

* [PATCH v2] net: stmmac: Fix signedness bug in stmmac_probe_config_dt()
  2020-08-18 14:39 [PATCH] net: stmmac: Fix signedness bug in stmmac_probe_config_dt() YueHaibing
  2020-08-18 14:51 ` Andreas Schwab
@ 2020-08-18 15:15 ` YueHaibing
  2020-08-18 17:04   ` Andrew Lunn
  1 sibling, 1 reply; 6+ messages in thread
From: YueHaibing @ 2020-08-18 15:15 UTC (permalink / raw)
  To: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, ajayg
  Cc: netdev, linux-stm32, linux-arm-kernel, linux-kernel, YueHaibing

The "plat->phy_interface" variable is an enum and in this context GCC
will treat it as an unsigned int so the error handling is never
triggered.

Fixes: b9f0b2f634c0 ("net: stmmac: platform: fix probe for ACPI devices")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: use rc to do err handling
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f32317fa75c8..a6052e980ec5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -412,10 +412,11 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
 		*mac = NULL;
 	}
 
-	plat->phy_interface = device_get_phy_mode(&pdev->dev);
-	if (plat->phy_interface < 0)
-		return ERR_PTR(plat->phy_interface);
+	rc = device_get_phy_mode(&pdev->dev);
+	if (rc < 0)
+		return ERR_PTR(rc);
 
+	plat->phy_interface = rc;
 	plat->interface = stmmac_of_get_mac_mode(np);
 	if (plat->interface < 0)
 		plat->interface = plat->phy_interface;
-- 
2.17.1



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

* Re: [PATCH] net: stmmac: Fix signedness bug in stmmac_probe_config_dt()
  2020-08-18 14:51 ` Andreas Schwab
@ 2020-08-18 15:15   ` Yuehaibing
  0 siblings, 0 replies; 6+ messages in thread
From: Yuehaibing @ 2020-08-18 15:15 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, ajayg, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

On 2020/8/18 22:51, Andreas Schwab wrote:
> On Aug 18 2020, YueHaibing wrote:
> 
>> The "plat->phy_interface" variable is an enum and in this context GCC
>> will treat it as an unsigned int so the error handling is never
>> triggered.
>>
>> Fixes: b9f0b2f634c0 ("net: stmmac: platform: fix probe for ACPI devices")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
>> ---
>>  drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> index f32317fa75c8..b5b558b02e7d 100644
>> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
>> @@ -413,7 +413,7 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac)
>>  	}
>>  
>>  	plat->phy_interface = device_get_phy_mode(&pdev->dev);
>> -	if (plat->phy_interface < 0)
>> +	if ((int)plat->phy_interface < 0)
>>  		return ERR_PTR(plat->phy_interface);
> 
> I don't think the conversion to long when passed to ERR_PTR will produce
> a negative value either (if long is wider than unsigned int).

Thanks, will respin.
> 
> Andreas.
> 


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

* Re: [PATCH v2] net: stmmac: Fix signedness bug in stmmac_probe_config_dt()
  2020-08-18 15:15 ` [PATCH v2] " YueHaibing
@ 2020-08-18 17:04   ` Andrew Lunn
  2020-08-20  2:23     ` Yuehaibing
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Lunn @ 2020-08-18 17:04 UTC (permalink / raw)
  To: YueHaibing
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, ajayg, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

On Tue, Aug 18, 2020 at 11:15:00PM +0800, YueHaibing wrote:
> The "plat->phy_interface" variable is an enum and in this context GCC
> will treat it as an unsigned int so the error handling is never
> triggered.
> 
> Fixes: b9f0b2f634c0 ("net: stmmac: platform: fix probe for ACPI devices")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>

Hi YueHaibing

Please take a look at:

commit 0c65b2b90d13c1deaee6449304dd367c5d4eb8ae
Author: Andrew Lunn <andrew@lunn.ch>
Date:   Mon Nov 4 02:40:33 2019 +0100

    net: of_get_phy_mode: Change API to solve int/unit warnings

You probably want to follow this basic idea.

    Andrew

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

* Re: [PATCH v2] net: stmmac: Fix signedness bug in stmmac_probe_config_dt()
  2020-08-18 17:04   ` Andrew Lunn
@ 2020-08-20  2:23     ` Yuehaibing
  0 siblings, 0 replies; 6+ messages in thread
From: Yuehaibing @ 2020-08-20  2:23 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, davem, kuba,
	mcoquelin.stm32, ajayg, netdev, linux-stm32, linux-arm-kernel,
	linux-kernel

On 2020/8/19 1:04, Andrew Lunn wrote:
> On Tue, Aug 18, 2020 at 11:15:00PM +0800, YueHaibing wrote:
>> The "plat->phy_interface" variable is an enum and in this context GCC
>> will treat it as an unsigned int so the error handling is never
>> triggered.
>>
>> Fixes: b9f0b2f634c0 ("net: stmmac: platform: fix probe for ACPI devices")
>> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> 
> Hi YueHaibing
> 
> Please take a look at:
> 
> commit 0c65b2b90d13c1deaee6449304dd367c5d4eb8ae
> Author: Andrew Lunn <andrew@lunn.ch>
> Date:   Mon Nov 4 02:40:33 2019 +0100
> 
>     net: of_get_phy_mode: Change API to solve int/unit warnings
> 
> You probably want to follow this basic idea.
> 

Thanks, will rework following this.

>     Andrew
> 
> .
> 


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

end of thread, other threads:[~2020-08-20  2:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 14:39 [PATCH] net: stmmac: Fix signedness bug in stmmac_probe_config_dt() YueHaibing
2020-08-18 14:51 ` Andreas Schwab
2020-08-18 15:15   ` Yuehaibing
2020-08-18 15:15 ` [PATCH v2] " YueHaibing
2020-08-18 17:04   ` Andrew Lunn
2020-08-20  2:23     ` Yuehaibing

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