Skip to contentSkip to conversation

enetc: Fix a signedness bug in enetc_of_get_phy()

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

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

PATCH 1/1 enetc: Fix a signedness bug in enetc_of_get_phy()

The "priv->if_mode" is type phy_interface_t which is an enum. In this context GCC will treat the enum as an unsigned int so this error handling is never triggered.

Fixes d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet drivers")
---
 drivers/net/ethernet/freescale/enetc/enetc_pf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc_pf.c +1 -1
index 7d6513ff8507..b73421c3e25b 100644
@@ -785,7 +785,7 @@ static int enetc_of_get_phy(struct enetc_ndev_priv *priv)
 	}
 
 	priv->if_mode = of_get_phy_mode(np);
-	if (priv->if_mode < 0) {
+	if ((int)priv->if_mode < 0) {
 		dev_err(priv->dev, "missing phy type\n");
 		of_node_put(priv->phy_node);
 		if (of_phy_is_fixed_link(np))
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw

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

Quoted 6 lines

The "priv->if_mode" is type phy_interface_t which is an enum. In this context GCC will treat the enum as an unsigned int so this error handling is never triggered.

Fixes d4fd0404c1c9 ("enetc: Introduce basic PF and VF ENETC ethernet drivers")

Applied.