Re: [bug report] net: pcs: xpcs: convert to phylink_pcs_ops

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

 



Hello Dan Carpenter,

On Tue, Jun 08, 2021 at 03:23:42PM +0300, Dan Carpenter wrote:
> Hello Vladimir Oltean,
> 
> The patch 11059740e616: "net: pcs: xpcs: convert to phylink_pcs_ops"
> from Jun 2, 2021, leads to the following static checker warning:
> 
> 	drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:1237 stmmac_phy_setup()
> 	error: we previously assumed 'mdio_bus_data' could be null (see line 1225)
> 
> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
>   1215  static int stmmac_phy_setup(struct stmmac_priv *priv)
>   1216  {
>   1217          struct stmmac_mdio_bus_data *mdio_bus_data = priv->plat->mdio_bus_data;
>                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   1218          struct fwnode_handle *fwnode = of_fwnode_handle(priv->plat->phylink_node);
>   1219          int mode = priv->plat->phy_interface;
>   1220          struct phylink *phylink;
>   1221  
>   1222          priv->phylink_config.dev = &priv->dev->dev;
>   1223          priv->phylink_config.type = PHYLINK_NETDEV;
>   1224          priv->phylink_config.pcs_poll = true;
>   1225          if (priv->plat->mdio_bus_data)
>                     ^^^^^^^^^^^^^^^^^^^^^^^^^
> This old code assumes mdio_bus_data can be NULL.
> 
>   1226                  priv->phylink_config.ovr_an_inband =
>   1227                          mdio_bus_data->xpcs_an_inband;
>   1228  
>   1229          if (!fwnode)
>   1230                  fwnode = dev_fwnode(priv->device);
>   1231  
>   1232          phylink = phylink_create(&priv->phylink_config, fwnode,
>   1233                                   mode, &stmmac_phylink_mac_ops);
>   1234          if (IS_ERR(phylink))
>   1235                  return PTR_ERR(phylink);
>   1236  
>   1237          if (mdio_bus_data->has_xpcs) {
>                     ^^^^^^^^^^^^^^^^^^^^^^^
> Unchecked dereference.
> 
>   1238                  struct mdio_xpcs_args *xpcs = priv->hw->xpcs;
>   1239  
>   1240                  phylink_set_pcs(phylink, &xpcs->pcs);
>   1241          }
>   1242  
>   1243          priv->phylink = phylink;
>   1244          return 0;
>   1245  }
> 
> regards,
> dan carpenter

This should be solved here:
https://lore.kernel.org/netdev/20210604112825.011148a3@xxxxxxxxxxxxxxxx/



[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