Commit b255ef45 authored by Vitalii Mordan's avatar Vitalii Mordan Committed by Jakub Kicinski
Browse files

eth: bcmsysport: fix call balance of priv->clk handling routines



Check the return value of clk_prepare_enable to ensure that priv->clk has
been successfully enabled.

If priv->clk was not enabled during bcm_sysport_probe, bcm_sysport_resume,
or bcm_sysport_open, it must not be disabled in any subsequent execution
paths.

Fixes: 31bc72d9 ("net: systemport: fetch and use clock resources")
Signed-off-by: default avatarVitalii Mordan <mordan@ispras.ru>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Link: https://patch.msgid.link/20241227123007.2333397-1-mordan@ispras.ru


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent a024e377
Loading
Loading
Loading
Loading
+18 −3
Original line number Diff line number Diff line
@@ -1933,7 +1933,11 @@ static int bcm_sysport_open(struct net_device *dev)
	unsigned int i;
	int ret;

	clk_prepare_enable(priv->clk);
	ret = clk_prepare_enable(priv->clk);
	if (ret) {
		netdev_err(dev, "could not enable priv clock\n");
		return ret;
	}

	/* Reset UniMAC */
	umac_reset(priv);
@@ -2591,7 +2595,11 @@ static int bcm_sysport_probe(struct platform_device *pdev)
		goto err_deregister_notifier;
	}

	clk_prepare_enable(priv->clk);
	ret = clk_prepare_enable(priv->clk);
	if (ret) {
		dev_err(&pdev->dev, "could not enable priv clock\n");
		goto err_deregister_netdev;
	}

	priv->rev = topctrl_readl(priv, REV_CNTL) & REV_MASK;
	dev_info(&pdev->dev,
@@ -2605,6 +2613,8 @@ static int bcm_sysport_probe(struct platform_device *pdev)

	return 0;

err_deregister_netdev:
	unregister_netdev(dev);
err_deregister_notifier:
	unregister_netdevice_notifier(&priv->netdev_notifier);
err_deregister_fixed_link:
@@ -2774,7 +2784,12 @@ static int __maybe_unused bcm_sysport_resume(struct device *d)
	if (!netif_running(dev))
		return 0;

	clk_prepare_enable(priv->clk);
	ret = clk_prepare_enable(priv->clk);
	if (ret) {
		netdev_err(dev, "could not enable priv clock\n");
		return ret;
	}

	if (priv->wolopts)
		clk_disable_unprepare(priv->wol_clk);