Skip to contentSkip to conversation

net: mii: report 0 for unknown lp_advertising

PATCH Applied Arnd Bergmann 2 participants 3 messages Nov 8, 2016 – Nov 10, 2016

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

PATCH 1/1 net: mii: report 0 for unknown lp_advertising

The newly introduced mii_ethtool_get_link_ksettings function sets lp_advertising to an uninitialized value when BMCR_ANENABLE is not set:

drivers/net/mii.c: In function 'mii_ethtool_get_link_ksettings':
drivers/net/mii.c:224:2: error: 'lp_advertising' may be used uninitialized in this function [-Werror=maybe-uninitialized]

As documented in include/uapi/linux/ethtool.h, the value is expected to be zero when we don't know it, so let's initialize it to that.

Fixes bc8ee596afe8 ("net: mii: add generic function to support ksetting support")
---
 drivers/net/mii.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/mii.c +2 -0
index 0443546fc427..6d953c53eed6 100644
@@ -213,6 +213,8 @@ int mii_ethtool_get_link_ksettings(struct mii_if_info *mii,
 				    SPEED_100 : SPEED_10));
 		cmd->base.duplex = (bmcr & BMCR_FULLDPLX) ?
 			DUPLEX_FULL : DUPLEX_HALF;
+
+		lp_advertising = 0;
 	}
 
 	mii->full_duplex = cmd->base.duplex;
Signature · 1 line
2.9.0
#1 lore raw
Quoted 7 lines · CET Arnd Bergmann

The newly introduced mii_ethtool_get_link_ksettings function sets lp_advertising to an uninitialized value when BMCR_ANENABLE is not set:

drivers/net/mii.c: In function 'mii_ethtool_get_link_ksettings':
drivers/net/mii.c:224:2: error: 'lp_advertising' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 6 lines

As documented in include/uapi/linux/ethtool.h, the value is expected to be zero when we don't know it, so let's initialize it to that.

Fixes bc8ee596afe8 ("net: mii: add generic function to support ksetting support")

In case there was any doubt: the patch causing this is currently in net-next and has just shown up in linux-next.

Arnd

maintainer Applied
#2 lore raw
In reply to Arnd Bergmann

From: Arnd Bergmann <[email protected]>
Date: Tue, 8 Nov 2016 14:31:38 +0100

Quoted 7 lines

The newly introduced mii_ethtool_get_link_ksettings function sets lp_advertising to an uninitialized value when BMCR_ANENABLE is not set:

drivers/net/mii.c: In function 'mii_ethtool_get_link_ksettings':
drivers/net/mii.c:224:2: error: 'lp_advertising' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Quoted 6 lines

As documented in include/uapi/linux/ethtool.h, the value is expected to be zero when we don't know it, so let's initialize it to that.

Fixes bc8ee596afe8 ("net: mii: add generic function to support ksetting support")

Applied.