Skip to contentSkip to conversation

net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle

PATCH Applied Thomas Fourier 3 participants 3 messages Feb 13 – Feb 18

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle

dma_free_coherent() in error path takes priv->rx_buf.alloc_len as the dma handle. This would lead to improper unmapping of the buffer.

Change the dma handle to priv->rx_buf.alloc_phys.

Fixes 6af55ff52b02 ("Driver for Beckhoff CX5020 EtherCAT master module.")
---
 drivers/net/ethernet/ec_bhf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ec_bhf.c +1 -1
index 67275aa4f65b..0c86cbb0313c 100644
@@ -423,7 +423,7 @@ static int ec_bhf_open(struct net_device *net_dev)
 
 error_rx_free:
 	dma_free_coherent(dev, priv->rx_buf.alloc_len, priv->rx_buf.alloc,
-			  priv->rx_buf.alloc_len);
+			  priv->rx_buf.alloc_phys);
 out:
 	return err;
 }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 4 lines

dma_free_coherent() in error path takes priv->rx_buf.alloc_len as the dma handle. This would lead to improper unmapping of the buffer.

Change the dma handle to priv->rx_buf.alloc_phys.

* Were any source code analysis tools involved here?

* You should probably specify message recipients not only in the header field “Cc”.

Regards,
Markus

#2 lore raw
In reply to Thomas Fourier
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Fri, 13 Feb 2026 17:43:39 +0100 you wrote:

dma_free_coherent() in error path takes priv->rx_buf.alloc_len as the dma handle. This would lead to improper unmapping of the buffer.

Change the dma handle to priv->rx_buf.alloc_phys.

Fixes 6af55ff52b02 ("Driver for Beckhoff CX5020 EtherCAT master module.")

[...]

Here is the summary with links:
- [net] net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle

    https://git.kernel.org/netdev/net/c/ffe68c376699

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html