[bug report] net: stmmac: Add glue layer for StarFive JH7110 SoC

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

 



Hello Samin Guo,

The patch 4bd3bb7b4526: "net: stmmac: Add glue layer for StarFive
JH7110 SoC" from Apr 17, 2023, leads to the following Smatch static
checker warning:

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c:148 starfive_dwmac_probe()
warn: inconsistent refcounting 'plat_dat->mdio_node->kobj.kref.refcount.refs.counter':
  inc on: 113,117,122,140
  dec on: 145

drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
    93 static int starfive_dwmac_probe(struct platform_device *pdev)
    94 {
    95         struct plat_stmmacenet_data *plat_dat;
    96         struct stmmac_resources stmmac_res;
    97         struct starfive_dwmac *dwmac;
    98         struct clk *clk_gtx;
    99         int err;
    100 
    101         err = stmmac_get_platform_resources(pdev, &stmmac_res);
    102         if (err)
    103                 return dev_err_probe(&pdev->dev, err,
    104                                      "failed to get resources\n");
    105 
    106         plat_dat = stmmac_probe_config_dt(pdev, stmmac_res.mac);
    107         if (IS_ERR(plat_dat))
    108                 return dev_err_probe(&pdev->dev, PTR_ERR(plat_dat),
    109                                      "dt configuration failed\n");

All the error paths after stmmac_probe_config_dt() succeeds should call
stmmac_remove_config_dt() but only the last one does.

    110 
    111         dwmac = devm_kzalloc(&pdev->dev, sizeof(*dwmac), GFP_KERNEL);
    112         if (!dwmac)
    113                 return -ENOMEM;
    114 
    115         dwmac->clk_tx = devm_clk_get_enabled(&pdev->dev, "tx");
    116         if (IS_ERR(dwmac->clk_tx))
    117                 return dev_err_probe(&pdev->dev, PTR_ERR(dwmac->clk_tx),
    118                                      "error getting tx clock\n");
    119 
    120         clk_gtx = devm_clk_get_enabled(&pdev->dev, "gtx");
    121         if (IS_ERR(clk_gtx))
    122                 return dev_err_probe(&pdev->dev, PTR_ERR(clk_gtx),
    123                                      "error getting gtx clock\n");
    124 
    125         /* Generally, the rgmii_tx clock is provided by the internal clock,
    126          * which needs to match the corresponding clock frequency according
    127          * to different speeds. If the rgmii_tx clock is provided by the
    128          * external rgmii_rxin, there is no need to configure the clock
    129          * internally, because rgmii_rxin will be adaptively adjusted.
    130          */
    131         if (!device_property_read_bool(&pdev->dev, "starfive,tx-use-rgmii-clk"))
    132                 plat_dat->fix_mac_speed = starfive_dwmac_fix_mac_speed;
    133 
    134         dwmac->dev = &pdev->dev;
    135         plat_dat->bsp_priv = dwmac;
    136         plat_dat->dma_cfg->dche = true;
    137 
    138         err = starfive_dwmac_set_mode(plat_dat);
    139         if (err)
    140                 return err;
    141 
    142         err = stmmac_dvr_probe(&pdev->dev, plat_dat, &stmmac_res);
    143         if (err) {
    144                 stmmac_remove_config_dt(pdev, plat_dat);
    145                 return err;
    146         }
    147 
--> 148         return 0;
    149 }

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