Skip to contentSkip to conversation

net: socionext: Fix a signedness bug in ave_probe()

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

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

PATCH 1/1 net: socionext: Fix a signedness bug in ave_probe()

The "phy_mode" variable is an enum and in this context GCC treats it as an unsigned int so the error handling is never triggered.

Fixes 4c270b55a5af ("net: ethernet: socionext: add AVE ethernet driver")
---
 drivers/net/ethernet/socionext/sni_ave.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/socionext/sni_ave.c +1 -1
index 10d0c3e478ab..d047a53f34f2 100644
@@ -1566,7 +1566,7 @@ static int ave_probe(struct platform_device *pdev)
 
 	np = dev->of_node;
 	phy_mode = of_get_phy_mode(np);
-	if (phy_mode < 0) {
+	if ((int)phy_mode < 0) {
 		dev_err(dev, "phy-mode not found\n");
 		return -EINVAL;
 	}
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Dan,

Thank you for pointing out.
I've confirmed that this error handling works well with your patch.

Thank you,

Quoted 24 lines · On Wed, 25 Sep 2019 13:57:50 +0300 <[email protected]> wrote:

The "phy_mode" variable is an enum and in this context GCC treats it as an unsigned int so the error handling is never triggered.

Fixes 4c270b55a5af ("net: ethernet: socionext: add AVE ethernet driver")
---
 drivers/net/ethernet/socionext/sni_ave.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/socionext/sni_ave.c +1 -1
index 10d0c3e478ab..d047a53f34f2 100644
@@ -1566,7 +1566,7 @@ static int ave_probe(struct platform_device *pdev)
 
 	np = dev->of_node;
 	phy_mode = of_get_phy_mode(np);
-	if (phy_mode < 0) {
+	if ((int)phy_mode < 0) {
 		dev_err(dev, "phy-mode not found\n");
 		return -EINVAL;
 	}
Signature · 1 line
2.20.1

---
Best Regards,
Kunihiko Hayashi