diff mbox series

[v2] net: stmmac: Fix signedness bug in stmmac_probe_config_dt()

Message ID 20200818151500.51548-1-yuehaibing@huawei.com (mailing list archive)
State New, archived
Headers show
Series [v2] net: stmmac: Fix signedness bug in stmmac_probe_config_dt() | expand

Commit Message

Yue Haibing Aug. 18, 2020, 3:15 p.m. UTC
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(-)

Comments

Andrew Lunn Aug. 18, 2020, 5:04 p.m. UTC | #1
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
Yue Haibing Aug. 20, 2020, 2:23 a.m. UTC | #2
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
> 
> .
>
diff mbox series

Patch

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;