Skip to content

Commit 84c65d8

Browse files
dlechjic23
authored andcommitted
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: 2d6ca60 ("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>
1 parent 90826e0 commit 84c65d8

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/iio/buffer/industrialio-buffer-dmaengine.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,
237237

238238
ret = dma_get_slave_caps(chan, &caps);
239239
if (ret < 0)
240-
goto err_free;
240+
goto err_release;
241241

242242
/* Needs to be aligned to the maximum of the minimums */
243243
if (caps.src_addr_widths)
@@ -263,6 +263,8 @@ static struct iio_buffer *iio_dmaengine_buffer_alloc(struct device *dev,
263263

264264
return &dmaengine_buffer->queue.buffer;
265265

266+
err_release:
267+
dma_release_channel(chan);
266268
err_free:
267269
kfree(dmaengine_buffer);
268270
return ERR_PTR(ret);

0 commit comments

Comments
 (0)