mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 20:14:06 +02:00
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) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Simon Horman <horms@kernel.org>
Fixes: a045e40645 ("net: stmmac: refactor clock management in EQoS driver")
Link: https://patch.msgid.link/E1ukM1X-0086qu-Td@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
de1e963ad0
commit
89886abd07
|
|
@ -330,15 +330,11 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
|
|||
if (IS_ERR(plat_dat))
|
||||
return PTR_ERR(plat_dat);
|
||||
|
||||
ret = devm_clk_bulk_get_all(&pdev->dev, &plat_dat->clks);
|
||||
ret = devm_clk_bulk_get_all_enabled(&pdev->dev, &plat_dat->clks);
|
||||
if (ret < 0)
|
||||
return dev_err_probe(&pdev->dev, ret, "Failed to retrieve all required clocks\n");
|
||||
return dev_err_probe(&pdev->dev, ret, "Failed to retrieve and enable all required clocks\n");
|
||||
plat_dat->num_clks = ret;
|
||||
|
||||
ret = clk_bulk_prepare_enable(plat_dat->num_clks, plat_dat->clks);
|
||||
if (ret)
|
||||
return dev_err_probe(&pdev->dev, ret, "Failed to enable clocks\n");
|
||||
|
||||
plat_dat->stmmac_clk = stmmac_pltfr_find_clk(plat_dat,
|
||||
data->stmmac_clk_name);
|
||||
|
||||
|
|
@ -346,7 +342,6 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
|
|||
ret = data->probe(pdev, plat_dat, &stmmac_res);
|
||||
if (ret < 0) {
|
||||
dev_err_probe(&pdev->dev, ret, "failed to probe subdriver\n");
|
||||
clk_bulk_disable_unprepare(plat_dat->num_clks, plat_dat->clks);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -370,15 +365,11 @@ static int dwc_eth_dwmac_probe(struct platform_device *pdev)
|
|||
static void dwc_eth_dwmac_remove(struct platform_device *pdev)
|
||||
{
|
||||
const struct dwc_eth_dwmac_data *data = device_get_match_data(&pdev->dev);
|
||||
struct plat_stmmacenet_data *plat_dat = dev_get_platdata(&pdev->dev);
|
||||
|
||||
stmmac_dvr_remove(&pdev->dev);
|
||||
|
||||
if (data->remove)
|
||||
data->remove(pdev);
|
||||
|
||||
if (plat_dat)
|
||||
clk_bulk_disable_unprepare(plat_dat->num_clks, plat_dat->clks);
|
||||
}
|
||||
|
||||
static const struct of_device_id dwc_eth_dwmac_match[] = {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user