summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <dlechner@baylibre.com>2024-07-23 11:32:21 -0500
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2024-07-29 20:31:23 +0100
commit84c65d8008764a8fb4e627ff02de01ec4245f2c4 (patch)
tree35c9b8895ba0cc16dc541220a1438482027f8467
parent90826e08468ba7fb35d8b39645b22d9e80004afe (diff)
downloadlinux-84c65d8008764a8fb4e627ff02de01ec4245f2c4.tar.gz
linux-84c65d8008764a8fb4e627ff02de01ec4245f2c4.tar.bz2
linux-84c65d8008764a8fb4e627ff02de01ec4245f2c4.zip
iio: buffer-dmaengine: fix releasing dma channel on error
If dma_get_slave_caps() fails, we need to release the dma channel before returning an error to avoid leaking the channel. Fixes: 2d6ca60f3284 ("iio: Add a DMAengine framework based buffer") Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20240723-iio-fix-dmaengine-free-on-error-v1-1-2c7cbc9b92ff@baylibre.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
-rw-r--r--drivers/iio/buffer/industrialio-buffer-dmaengine.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/iio/buffer/industrialio-buffer-dmaengine.c b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
index 12aa1412dfa0..426cc614587a 100644
--- a/drivers/iio/buffer/industrialio-buffer-dmaengine.c
+++ b/drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -237,7 +237,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,
ret = dma_get_slave_caps(chan, &caps);
if (ret < 0)
- goto err_free;
+ goto err_release;
/* Needs to be aligned to the maximum of the minimums */
if (caps.src_addr_widths)
@@ -263,6 +263,8 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,
return &dmaengine_buffer->queue.buffer;
+err_release:
+ dma_release_channel(chan);
err_free:
kfree(dmaengine_buffer);
return ERR_PTR(ret);