[bug report] net: dsa: qca8k: add support for switch rev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Ansuel Smith,

The patch 95ffeaf18b3b: "net: dsa: qca8k: add support for switch rev"
from May 14, 2021, leads to the following static checker warning:

drivers/net/dsa/qca8k.c:163 qca8k_read() warn: unsigned 'val' is never less than zero.
drivers/net/dsa/qca8k.c:212 qca8k_rmw() warn: unsigned 'val' is never less than zero.
drivers/net/dsa/qca8k.c:309 qca8k_busy_wait() warn: unsigned 'val' is never less than zero.
drivers/net/dsa/qca8k.c:324 qca8k_fdb_read() warn: unsigned 'val' is never less than zero.
drivers/net/dsa/qca8k.c:400 qca8k_fdb_access() warn: unsigned 'reg' is never less than zero.
drivers/net/dsa/qca8k.c:481 qca8k_vlan_access() warn: unsigned 'reg' is never less than zero.
drivers/net/dsa/qca8k.c:509 qca8k_vlan_add() warn: unsigned 'reg' is never less than zero.
drivers/net/dsa/qca8k.c:544 qca8k_vlan_del() warn: unsigned 'reg' is never less than zero.
drivers/net/dsa/qca8k.c:648 qca8k_mdio_busy_wait() warn: unsigned 'val' is never less than zero.
drivers/net/dsa/qca8k.c:1315 qca8k_phylink_mac_link_state() warn: unsigned 'reg' is never less than zero.
drivers/net/dsa/qca8k.c:1425 qca8k_get_ethtool_stats() warn: unsigned 'val' is never less than zero.
drivers/net/dsa/qca8k.c:1430 qca8k_get_ethtool_stats() warn: unsigned 'hi' is never less than zero.
drivers/net/dsa/qca8k.c:1459 qca8k_set_mac_eee() warn: unsigned 'reg' is never less than zero.
drivers/net/dsa/qca8k.c:1799 qca8k_read_switch_id() warn: unsigned 'val' is never less than zero.

drivers/net/dsa/qca8k.c:732 qca8k_mdio_read() warn: always true condition '(val >= 0) => (0-u32max >= 0)'

drivers/net/dsa/qca8k.c
   151  static u32
               ^^^
This is a unsigned, but the callers expect int.  Which is harmless but
kind of messy.

   152  qca8k_read(struct qca8k_priv *priv, u32 reg)
   153  {
   154          struct mii_bus *bus = priv->bus;
   155          u16 r1, r2, page;
   156          u32 val;
   157  
   158          qca8k_split_addr(reg, &r1, &r2, &page);
   159  
   160          mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
   161  
   162          val = qca8k_set_page(bus, page);
   163          if (val < 0)

Obviously unsigned can't be less than zero.

   164                  goto exit;
   165  
   166          val = qca8k_mii_read32(bus, 0x10 | r2, r1);

How high can this be?  In real life I expect that it's fine and there
are few times where we actually need to go over INT_MAX (2 million
should be enough for anybody), but it might be better to not mix this
with error codes?

   167  
   168  exit:
   169          mutex_unlock(&bus->mdio_lock);
   170          return val;
   171  }

regards,
dan carpenter



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux