[PATCH net] net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle

Thomas Fourier posted 1 patch 1 month, 2 weeks ago
drivers/net/ethernet/ec_bhf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH net] net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle
Posted by Thomas Fourier 1 month, 2 weeks ago
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.")
Cc: <stable@vger.kernel.org>
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/net/ethernet/ec_bhf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ec_bhf.c b/drivers/net/ethernet/ec_bhf.c
index 67275aa4f65b..0c86cbb0313c 100644
--- a/drivers/net/ethernet/ec_bhf.c
+++ b/drivers/net/ethernet/ec_bhf.c
@@ -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;
 }
-- 
2.43.0
Re: [PATCH net] net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle
Posted by Markus Elfring 1 month, 2 weeks ago
> 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