Blob Blame History Raw
From: YueHaibing <yuehaibing@huawei.com>
Date: Wed, 7 Jul 2021 15:53:35 +0800
Subject: stmmac: platform: Fix signedness bug in stmmac_probe_config_dt()

Git-commit: eca81f09145d765c21dd8fb1ba5d874ca255c32c
Patch-mainline: v5.14-rc2
References: git-fixes

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Mian Yousaf Kaukab <ykaukab@suse.de>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -369,6 +369,7 @@ stmmac_probe_config_dt(struct platform_d
 	struct device_node *np = pdev->dev.of_node;
 	struct plat_stmmacenet_data *plat;
 	struct stmmac_dma_cfg *dma_cfg;
+	int phy_mode;
 	int rc;
 
 	plat = devm_kzalloc(&pdev->dev, sizeof(*plat), GFP_KERNEL);
@@ -409,7 +409,12 @@ stmmac_probe_config_dt(struct platform_d
 		*mac = NULL;
 	}
 
-	plat->phy_interface = device_get_phy_mode(&pdev->dev);
+	phy_mode = device_get_phy_mode(&pdev->dev);
+	if (phy_mode < 0)
+		return ERR_PTR(phy_mode);
+
+	plat->interface = phy_mode;
+
 	if (plat->phy_interface < 0)
 		return ERR_PTR(plat->phy_interface);