[<prev] [next>] [day] [month] [year] [list]
Message-ID: <6bfe7399c41d8b50a05b050832c6061d3fc04762.1765004907.git.christophe.jaillet@wanadoo.fr>
Date: Sat, 6 Dec 2025 08:08:52 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Dave Penkler <dpenkler@...il.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org,
Christophe JAILLET <christophe.jaillet@...adoo.fr>
Subject: [PATCH] gpib: fluke: Add some missing dma_unmap_single()
In some error handling paths, a dma_unmap_single() is missing.
Add it to avoid a leak.
Fixes: 55936779f496 ("staging: gpib: Add Fluke cda based cards GPIB driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
This patch is compile tested only.
---
drivers/gpib/eastwood/fluke_gpib.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpib/eastwood/fluke_gpib.c b/drivers/gpib/eastwood/fluke_gpib.c
index 61eca22dc2b0..1ef5c16a81ba 100644
--- a/drivers/gpib/eastwood/fluke_gpib.c
+++ b/drivers/gpib/eastwood/fluke_gpib.c
@@ -454,8 +454,10 @@ static int fluke_dma_write(struct gpib_board *board, u8 *buffer, size_t length,
retval = wait_for_sids_or_sgns(board);
*bytes_written = readl(e_priv->write_transfer_counter) & write_transfer_counter_mask;
- if (WARN_ON_ONCE(*bytes_written > length))
- return -EFAULT;
+ if (WARN_ON_ONCE(*bytes_written > length)) {
+ retval = -EFAULT;
+ goto cleanup;
+ }
cleanup:
dma_unmap_single(board->dev, address, length, DMA_TO_DEVICE);
@@ -641,8 +643,10 @@ static int fluke_dma_read(struct gpib_board *board, u8 *buffer,
*/
usleep_range(10, 15);
residue = fluke_get_dma_residue(e_priv->dma_channel, dma_cookie);
- if (WARN_ON_ONCE(residue > length || residue < 0))
+ if (WARN_ON_ONCE(residue > length || residue < 0)) {
+ dma_unmap_single(board->dev, bus_address, length, DMA_FROM_DEVICE);
return -EFAULT;
+ }
*bytes_read += length - residue;
dmaengine_terminate_all(e_priv->dma_channel);
// make sure fluke_dma_callback got called
--
2.52.0
Powered by blists - more mailing lists