Hello Jassi Brar, The patch 533dd11a12f6: "net: socionext: Add Synquacer NetSec driver" from Jan 6, 2018, leads to the following Smatch static checker warning: drivers/net/ethernet/socionext/netsec.c:1975 netsec_register_mdio() warn: inconsistent refcounting 'bus->dev.kobj.kset->kobj.kref.refcount.refs.counter': drivers/net/ethernet/socionext/netsec.c 1913 static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) 1914 { 1915 struct mii_bus *bus; 1916 int ret; 1917 1918 bus = devm_mdiobus_alloc(priv->dev); 1919 if (!bus) 1920 return -ENOMEM; 1921 1922 snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev_name(priv->dev)); 1923 bus->priv = priv; 1924 bus->name = "SNI NETSEC MDIO"; 1925 bus->read = netsec_phy_read; 1926 bus->write = netsec_phy_write; 1927 bus->parent = priv->dev; 1928 priv->mii_bus = bus; 1929 1930 if (dev_of_node(priv->dev)) { 1931 struct device_node *mdio_node, *parent = dev_of_node(priv->dev); 1932 1933 mdio_node = of_get_child_by_name(parent, "mdio"); 1934 if (mdio_node) { 1935 parent = mdio_node; 1936 } else { 1937 /* older f/w doesn't populate the mdio subnode, 1938 * allow relaxed upgrade of f/w in due time. 1939 */ 1940 dev_info(priv->dev, "Upgrade f/w for mdio subnode!\n"); 1941 } 1942 1943 ret = of_mdiobus_register(bus, parent); 1944 of_node_put(mdio_node); 1945 1946 if (ret) { 1947 dev_err(priv->dev, "mdiobus register err(%d)\n", ret); 1948 return ret; 1949 } 1950 } else { 1951 /* Mask out all PHYs from auto probing. */ 1952 bus->phy_mask = ~0; 1953 ret = mdiobus_register(bus); Why not use devm_mdiobus_register()? 1954 if (ret) { 1955 dev_err(priv->dev, "mdiobus register err(%d)\n", ret); 1956 return ret; 1957 } 1958 1959 priv->phydev = get_phy_device(bus, phy_addr, false); 1960 if (IS_ERR(priv->phydev)) { 1961 ret = PTR_ERR(priv->phydev); 1962 dev_err(priv->dev, "get_phy_device err(%d)\n", ret); No unregister. 1963 priv->phydev = NULL; 1964 return -ENODEV; 1965 } 1966 1967 ret = phy_device_register(priv->phydev); 1968 if (ret) { 1969 mdiobus_unregister(bus); This path has an unregister but doesn't clean up from get_phy_device(). 1970 dev_err(priv->dev, 1971 "phy_device_register err(%d)\n", ret); 1972 } 1973 } 1974 --> 1975 return ret; 1976 } regards, dan carpenter