> Hello Justin Lai, > > Commit a36e9f5cfe9e ("rtase: Add support for a pci table in this > module") from Sep 4, 2024 (linux-next), leads to the following Smatch > static checker warning: > > drivers/net/ethernet/realtek/rtase/rtase_main.c:2185 rtase_init_one() > warn: inconsistent refcounting 'pdev->enable_cnt.counter': > inc on: 2108 > dec on: 2185 > > drivers/net/ethernet/realtek/rtase/rtase_main.c > 2081 static int rtase_init_one(struct pci_dev *pdev, > 2082 const struct pci_device_id *ent) > 2083 { > 2084 struct net_device *dev = NULL; > 2085 struct rtase_int_vector *ivec; > 2086 void __iomem *ioaddr = NULL; > 2087 struct rtase_private *tp; > 2088 int ret, i; > 2089 > 2090 if (!pdev->is_physfn && pdev->is_virtfn) { > 2091 dev_err(&pdev->dev, > 2092 "This module does not support a > virtual function."); > 2093 return -EINVAL; > 2094 } > 2095 > 2096 dev_dbg(&pdev->dev, "Automotive Switch Ethernet driver > loaded\n"); > 2097 > 2098 ret = rtase_init_board(pdev, &dev, &ioaddr); > 2099 if (ret != 0) > 2100 return ret; > 2101 > 2102 tp = netdev_priv(dev); > 2103 tp->mmio_addr = ioaddr; > 2104 tp->dev = dev; > 2105 tp->pdev = pdev; > 2106 > 2107 /* identify chip attached to board */ > 2108 if (!rtase_check_mac_version_valid(tp)) > 2109 return dev_err_probe(&pdev->dev, -ENODEV, > 2110 "unknown chip version, > contact rtase maintainers (see MAINTAINERS file)\n"); > > The static checker wants this error path to do some cleanup. > > 2111 > 2112 rtase_init_software_variable(pdev, tp); > 2113 rtase_init_hardware(tp); > 2114 > 2115 ret = rtase_alloc_interrupt(pdev, tp); > 2116 if (ret < 0) { > 2117 dev_err(&pdev->dev, "unable to alloc > MSIX/MSI\n"); > 2118 goto err_out_1; > 2119 } > 2120 > 2121 rtase_init_netdev_ops(dev); > 2122 > 2123 dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS; > 2124 > 2125 dev->features |= NETIF_F_HW_VLAN_CTAG_TX | > NETIF_F_HW_VLAN_CTAG_RX | > 2126 NETIF_F_IP_CSUM | > NETIF_F_HIGHDMA | > 2127 NETIF_F_RXCSUM | NETIF_F_SG | > 2128 NETIF_F_TSO | NETIF_F_IPV6_CSUM > | > 2129 NETIF_F_TSO6; > 2130 > 2131 dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | > 2132 NETIF_F_TSO | NETIF_F_RXCSUM > | > 2133 NETIF_F_HW_VLAN_CTAG_TX | > NETIF_F_HW_VLAN_CTAG_RX | > 2134 NETIF_F_RXALL | NETIF_F_RXFCS > | > 2135 NETIF_F_IPV6_CSUM | > NETIF_F_TSO6; > 2136 > 2137 dev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | > NETIF_F_TSO | > 2138 NETIF_F_HIGHDMA; > 2139 dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; > 2140 netif_set_tso_max_size(dev, RTASE_LSO_64K); > 2141 netif_set_tso_max_segs(dev, > RTASE_NIC_MAX_PHYS_BUF_COUNT_LSO2); > 2142 > 2143 rtase_get_mac_address(dev); > 2144 > 2145 tp->tally_vaddr = dma_alloc_coherent(&pdev->dev, > 2146 > sizeof(*tp->tally_vaddr), > 2147 > &tp->tally_paddr, > 2148 > GFP_KERNEL); > 2149 if (!tp->tally_vaddr) { > 2150 ret = -ENOMEM; > 2151 goto err_out; > 2152 } > 2153 > 2154 rtase_tally_counter_clear(tp); > 2155 > 2156 pci_set_drvdata(pdev, dev); > 2157 > 2158 netif_carrier_off(dev); > 2159 > 2160 ret = register_netdev(dev); > 2161 if (ret != 0) > 2162 goto err_out; > 2163 > 2164 netdev_dbg(dev, "%pM, IRQ %d\n", dev->dev_addr, > dev->irq); > 2165 > 2166 return 0; > 2167 > 2168 err_out: > 2169 if (tp->tally_vaddr) { > 2170 dma_free_coherent(&pdev->dev, > 2171 sizeof(*tp->tally_vaddr), > 2172 tp->tally_vaddr, > 2173 tp->tally_paddr); > 2174 > 2175 tp->tally_vaddr = NULL; > 2176 } > 2177 > 2178 err_out_1: > 2179 for (i = 0; i < tp->int_nums; i++) { > 2180 ivec = &tp->int_vector[i]; > 2181 netif_napi_del(&ivec->napi); > 2182 } > 2183 > 2184 rtase_release_board(pdev, dev, ioaddr); > --> 2185 > 2186 return ret; > 2187 } > > regards, > dan carpenter Thank you for pointing out this warning. I will look into it and submit a revised patch to resolve the issue. Thanks Justin