Skip to content

Commit

Permalink
iio: buffer-dmaengine: fix releasing dma channel on error
Browse files Browse the repository at this point in the history
commit 84c65d8 upstream.

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 <[email protected]>
Link: https://patch.msgid.link/20240723-iio-fix-dmaengine-free-on-error-v1-1-2c7cbc9b92ff@baylibre.com
Cc: <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
dlech authored and gregkh committed Sep 12, 2024
1 parent dc12e49 commit cb0f3f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/iio/buffer/industrialio-buffer-dmaengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ 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)
Expand All @@ -206,6 +206,8 @@ 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);
Expand Down

0 comments on commit cb0f3f0

Please sign in to comment.