Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.")
Cc: <stable@vger.kernel.org>
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Link: https://patch.msgid.link/20260213164340.77272-2-fourier.thomas@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Thomas Fourier and committed by
Jakub Kicinski
ffe68c37 e3f000f0

+1 -1
+1 -1
drivers/net/ethernet/ec_bhf.c
··· 423 423 424 424 error_rx_free: 425 425 dma_free_coherent(dev, priv->rx_buf.alloc_len, priv->rx_buf.alloc, 426 - priv->rx_buf.alloc_len); 426 + priv->rx_buf.alloc_phys); 427 427 out: 428 428 return err; 429 429 }