netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: moxa: do not call dma_unmap_single() with null
@ 2022-08-18 18:29 Sergei Antonov
  2022-08-18 18:29 ` [PATCH 2/2] net: moxa: prevent double-mapping of DMA areas Sergei Antonov
  2022-08-18 19:18 ` [PATCH 1/2] net: moxa: do not call dma_unmap_single() with null Andrew Lunn
  0 siblings, 2 replies; 7+ messages in thread
From: Sergei Antonov @ 2022-08-18 18:29 UTC (permalink / raw)
  To: netdev; +Cc: Andrew Lunn, Jakub Kicinski, Vladimir Oltean, Sergei Antonov

It fixes a warning during error unwinding:

WARNING: CPU: 0 PID: 1 at kernel/dma/debug.c:963 check_unmap+0x704/0x980
DMA-API: moxart-ethernet 92000000.mac: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=1600 bytes]
CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0+ #60
Hardware name: Generic DT based system
 unwind_backtrace from show_stack+0x10/0x14
 show_stack from dump_stack_lvl+0x34/0x44
 dump_stack_lvl from __warn+0xbc/0x1f0
 __warn from warn_slowpath_fmt+0x94/0xc8
 warn_slowpath_fmt from check_unmap+0x704/0x980
 check_unmap from debug_dma_unmap_page+0x8c/0x9c
 debug_dma_unmap_page from moxart_mac_free_memory+0x3c/0xa8
 moxart_mac_free_memory from moxart_mac_probe+0x190/0x218
 moxart_mac_probe from platform_probe+0x48/0x88
 platform_probe from really_probe+0xc0/0x2e4

Fixes: 6c821bd9edc9 ("net: Add MOXA ART SoCs ethernet driver")
Signed-off-by: Sergei Antonov <saproj@gmail.com>
---
 drivers/net/ethernet/moxa/moxart_ether.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c
index f11f1cb92025..edd1dab2ec43 100644
--- a/drivers/net/ethernet/moxa/moxart_ether.c
+++ b/drivers/net/ethernet/moxa/moxart_ether.c
@@ -77,8 +77,9 @@ static void moxart_mac_free_memory(struct net_device *ndev)
 	int i;
 
 	for (i = 0; i < RX_DESC_NUM; i++)
-		dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i],
-				 priv->rx_buf_size, DMA_FROM_DEVICE);
+		if (priv->rx_mapping[i])
+			dma_unmap_single(&priv->pdev->dev, priv->rx_mapping[i],
+					 priv->rx_buf_size, DMA_FROM_DEVICE);
 
 	if (priv->tx_desc_base)
 		dma_free_coherent(&priv->pdev->dev,
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-08-19 11:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-18 18:29 [PATCH 1/2] net: moxa: do not call dma_unmap_single() with null Sergei Antonov
2022-08-18 18:29 ` [PATCH 2/2] net: moxa: prevent double-mapping of DMA areas Sergei Antonov
2022-08-18 19:27   ` Andrew Lunn
2022-08-19  8:12     ` Sergei Antonov
2022-08-19 11:00       ` Vladimir Oltean
2022-08-18 19:18 ` [PATCH 1/2] net: moxa: do not call dma_unmap_single() with null Andrew Lunn
2022-08-19  7:27   ` Sergei Antonov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).