Skip to contentSkip to conversation

net: ethernet: stmmac: Fix signedness bug in ipq806x_gmac_of_parse()

PATCH Applied Dan Carpenter 2 participants 2 messages Sep 25, 2019 – Sep 27, 2019

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ethernet: stmmac: Fix signedness bug in ipq806x_gmac_of_parse()

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

Fixes b1c17215d718 ("stmmac: add ipq806x glue layer")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c +1 -1
index 2c6d7c69c8f7..0d21082ceb93 100644
@@ -191,7 +191,7 @@ static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
 	struct device *dev = &gmac->pdev->dev;
 
 	gmac->phy_mode = of_get_phy_mode(dev->of_node);
-	if (gmac->phy_mode < 0) {
+	if ((int)gmac->phy_mode < 0) {
 		dev_err(dev, "missing phy mode property\n");
 		return -EINVAL;
 	}
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw

From: Dan Carpenter <[email protected]>
Date: Wed, 25 Sep 2019 14:05:54 +0300

Quoted 6 lines

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

Fixes b1c17215d718 ("stmmac: add ipq806x glue layer")

Applied.