net: ethernet: ravb: Fix release of refclk
authorAdam Ford <aford173@gmail.com>
Wed, 21 Apr 2021 14:05:05 +0000 (09:05 -0500)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Apr 2021 18:17:09 +0000 (11:17 -0700)
The call to clk_disable_unprepare() can happen before priv is
initialized. This means moving clk_disable_unprepare out of
out_release into a new label.

Fixes: 8ef7adc6beb2 ("net: ethernet: ravb: Enable optional refclk")
Signed-off-by: Adam Ford <aford173@gmail.com>
Reviewed-by: Sergei Shtylyov <sergei.shtylyov@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/ravb_main.c

index 8c84c40ab9a0cb7aff72e4814b0b02c03fb5b140..9e5dad41cdc9be2d4d57037beac53326a8b92d3a 100644 (file)
@@ -2173,7 +2173,7 @@ static int ravb_probe(struct platform_device *pdev)
        /* Set GTI value */
        error = ravb_set_gti(ndev);
        if (error)
-               goto out_release;
+               goto out_disable_refclk;
 
        /* Request GTI loading */
        ravb_modify(ndev, GCCR, GCCR_LTI, GCCR_LTI);
@@ -2192,7 +2192,7 @@ static int ravb_probe(struct platform_device *pdev)
                        "Cannot allocate desc base address table (size %d bytes)\n",
                        priv->desc_bat_size);
                error = -ENOMEM;
-               goto out_release;
+               goto out_disable_refclk;
        }
        for (q = RAVB_BE; q < DBAT_ENTRY_NUM; q++)
                priv->desc_bat[q].die_dt = DT_EOS;
@@ -2252,8 +2252,9 @@ out_dma_free:
        /* Stop PTP Clock driver */
        if (chip_id != RCAR_GEN2)
                ravb_ptp_stop(ndev);
-out_release:
+out_disable_refclk:
        clk_disable_unprepare(priv->refclk);
+out_release:
        free_netdev(ndev);
 
        pm_runtime_put(&pdev->dev);