diff mbox series

[net,1/2] ravb: Fix dma_free_coherent() of desc_bat timing in ravb_remove()

Message ID 20231004091253.4194205-2-yoshihiro.shimoda.uh@renesas.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net,1/2] ravb: Fix dma_free_coherent() of desc_bat timing in ravb_remove() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1340 this patch: 1340
netdev/cc_maintainers fail 2 blamed authors not CCed: sergei.shtylyov@cogentembedded.com mitsuhiro.kimura.kc@renesas.com; 3 maintainers not CCed: sergei.shtylyov@cogentembedded.com wsa+renesas@sang-engineering.com mitsuhiro.kimura.kc@renesas.com
netdev/build_clang success Errors and warnings before: 1363 this patch: 1363
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1363 this patch: 1363
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yoshihiro Shimoda Oct. 4, 2023, 9:12 a.m. UTC
The dma_free_coherent() in ravb_remove() should be called 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>
---
 drivers/net/ethernet/renesas/ravb_main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Sergey Shtylyov Oct. 4, 2023, 6:46 p.m. UTC | #1
On 10/4/23 12:12 PM, Yoshihiro Shimoda wrote:

> The dma_free_coherent() in ravb_remove() should be called after

   How about:

In ravb_remove(), dma_free_coherent() should be called after unregister_netdev().

> 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>

[...]

MBR, Sergey
Sergey Shtylyov Oct. 4, 2023, 7:04 p.m. UTC | #2
Concerning the summary: how about the below?

ravb: fix up dma_free_coherent() call in ravb_remove()
Yoshihiro Shimoda Oct. 5, 2023, 12:26 a.m. UTC | #3
Hello Sergey,

> From: Sergey Shtylyov, Sent: Thursday, October 5, 2023 3:47 AM
> Subject: Re: [PATCH net 1/2] ravb: Fix dma_free_coherent() of desc_bat timing in ravb_remove()

Thank you for your suggestion in other thread. I'll fix the subject.

> On 10/4/23 12:12 PM, Yoshihiro Shimoda wrote:
> 
> > The dma_free_coherent() in ravb_remove() should be called after
> 
>    How about:
> 
> In ravb_remove(), dma_free_coherent() should be called after unregister_netdev().

I got it. I'll fix this.

> > 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>

Thank you for your review!

Best regards,
Yoshihiro Shimoda

> [...]
> 
> MBR, Sergey
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 7df9f9f8e134..9e2e801049cc 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -2891,8 +2891,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);
@@ -2900,6 +2898,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);