Skip to content

Commit 89886ab

Browse files
Russell King (Oracle)kuba-moo
authored andcommitted
net: stmmac: dwc-qos: fix clk prepare/enable leak on probe failure
dwc_eth_dwmac_probe() gets bulk clocks, and then prepares and enables them. Unfortunately, if dwc_eth_dwmac_config_dt() or stmmac_dvr_probe() fail, we leave the clocks prepared and enabled. Fix this by using devm_clk_bulk_get_all_enabled() to combine the steps and provide devm based release of the prepare and enable state. This also fixes a similar leakin dwc_eth_dwmac_remove() which wasn't correctly retrieving the struct plat_stmmacenet_data. This becomes unnecessary. Signed-off-by: Russell King (Oracle) <[email protected]> Reviewed-by: Simon Horman <[email protected]> Fixes: a045e40 ("net: stmmac: refactor clock management in EQoS driver") Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent de1e963 commit 89886ab

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -330,23 +330,18 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
330330
if (IS_ERR(plat_dat))
331331
return PTR_ERR(plat_dat);
332332

333-
ret = devm_clk_bulk_get_all(&pdev->dev, &plat_dat->clks);
333+
ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &plat_dat->clks);
334334
if (ret < 0)
335-
return dev_err_probe(&pdev->dev, ret, "Failed to retrieve all required clocks\n");
335+
return dev_err_probe(&pdev->dev, ret, "Failed to retrieve and enable all required clocks\n");
336336
plat_dat->num_clks = ret;
337337

338-
ret = clk_bulk_prepare_enable(plat_dat->num_clks, plat_dat->clks);
339-
if (ret)
340-
return dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
341-
342338
plat_dat->stmmac_clk = stmmac_pltfr_find_clk(plat_dat,
343339
data->stmmac_clk_name);
344340

345341
if (data->probe)
346342
ret = data->probe(pdev, plat_dat, &stmmac_res);
347343
if (ret < 0) {
348344
dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n");
349-
clk_bulk_disable_unprepare(plat_dat->num_clks, plat_dat->clks);
350345
return ret;
351346
}
352347

@@ -370,15 +365,11 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
370365
static void dwc_eth_dwmac_remove(struct platform_device *pdev)
371366
{
372367
const struct dwc_eth_dwmac_data *data = device_get_match_data(&pdev->dev);
373-
struct plat_stmmacenet_data *plat_dat = dev_get_platdata(&pdev->dev);
374368

375369
stmmac_dvr_remove(&pdev->dev);
376370

377371
if (data->remove)
378372
data->remove(pdev);
379-
380-
if (plat_dat)
381-
clk_bulk_disable_unprepare(plat_dat->num_clks, plat_dat->clks);
382373
}
383374

384375
static const struct of_device_id dwc_eth_dwmac_match[] = {

0 commit comments

Comments
 (0)