]> git.baikalelectronics.ru Git - kernel.git/commitdiff
ravb: Fix up dma_free_coherent() call in ravb_remove()
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Thu, 5 Oct 2023 01:12:00 +0000 (10:12 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Oct 2023 21:08:52 +0000 (23:08 +0200)
[ Upstream commit e6864af61493113558c502b5cd0d754c19b93277 ]

In ravb_remove(), dma_free_coherent() should be call after
unregister_netdev(). Otherwise, this controller is possible to use
the freed buffer.

Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
Link: https://lore.kernel.org/r/20231005011201.14368-2-yoshihiro.shimoda.uh@renesas.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/renesas/ravb_main.c

index 894e2690c64372a2beb3ab13907722e823b3ffef..4bf371f744a3558e534f0b3fd17eb815bc8f99d1 100644 (file)
@@ -2907,8 +2907,6 @@ static int ravb_remove(struct platform_device *pdev)
        clk_disable_unprepare(priv->gptp_clk);
        clk_disable_unprepare(priv->refclk);
 
-       dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
-                         priv->desc_bat_dma);
        /* Set reset mode */
        ravb_write(ndev, CCC_OPC_RESET, CCC);
        unregister_netdev(ndev);
@@ -2916,6 +2914,8 @@ static int ravb_remove(struct platform_device *pdev)
                netif_napi_del(&priv->napi[RAVB_NC]);
        netif_napi_del(&priv->napi[RAVB_BE]);
        ravb_mdio_release(priv);
+       dma_free_coherent(ndev->dev.parent, priv->desc_bat_size, priv->desc_bat,
+                         priv->desc_bat_dma);
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
        reset_control_assert(priv->rstc);