net: mii: report 0 for unknown lp_advertising
authorArnd Bergmann <arnd@arndb.de>
Tue, 8 Nov 2016 13:31:38 +0000 (14:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Nov 2016 01:26:58 +0000 (20:26 -0500)
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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/mii.c

index 0443546fc4274fe18850606f007d301b993ce744..6d953c53eed6c86d9c6db39704a374ee5fac1bde 100644 (file)
@@ -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;