[bug report] drivers/net/phy: add helpers to get/set PLCA configuration

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

 



Hello Piergiorgio Beruto,

The patch 493323416fed: "drivers/net/phy: add helpers to get/set PLCA
configuration" from Jan 9, 2023, leads to the following Smatch static
checker warning:

	drivers/net/phy/phy-c45.c:1036 genphy_c45_plca_set_cfg()
	error: uninitialized symbol 'val'.

drivers/net/phy/phy-c45.c
   999  int genphy_c45_plca_set_cfg(struct phy_device *phydev,
  1000                              const struct phy_plca_cfg *plca_cfg)
  1001  {
  1002          int ret;
  1003          u16 val;
  1004  
  1005          // PLCA IDVER is read-only
  1006          if (plca_cfg->version >= 0)
  1007                  return -EINVAL;
  1008  
  1009          // first of all, disable PLCA if required
  1010          if (plca_cfg->enabled == 0) {
  1011                  ret = phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2,
  1012                                           MDIO_OATC14_PLCA_CTRL0,
  1013                                           MDIO_OATC14_PLCA_EN);
  1014  
  1015                  if (ret < 0)
  1016                          return ret;
  1017          }
  1018  
  1019          // check if we need to set the PLCA node count, node ID, or both
  1020          if (plca_cfg->node_cnt >= 0 || plca_cfg->node_id >= 0) {

Let's assume both conditions are true

  1021                  /* if one between node count and node ID is -not- to be
  1022                   * changed, read the register to later perform merge/purge of
  1023                   * the configuration as appropriate
  1024                   */
  1025                  if (plca_cfg->node_cnt < 0 || plca_cfg->node_id < 0) {

Then neither condition is true here

  1026                          ret = phy_read_mmd(phydev, MDIO_MMD_VEND2,
  1027                                             MDIO_OATC14_PLCA_CTRL1);
  1028  
  1029                          if (ret < 0)
  1030                                  return ret;
  1031  
  1032                          val = ret;
  1033                  }
  1034  
  1035                  if (plca_cfg->node_cnt >= 0)
  1036                          val = (val & ~MDIO_OATC14_PLCA_NCNT) |
                                       ^^^
Uninitialized

  1037                                (plca_cfg->node_cnt << 8);
  1038  
  1039                  if (plca_cfg->node_id >= 0)
  1040                          val = (val & ~MDIO_OATC14_PLCA_ID) |
  1041                                (plca_cfg->node_id);


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