iio: core: Don't free buffer0 blocks when it's still in use via buffer fd API#3318
Open
nunojsa wants to merge 1 commit into
Open
iio: core: Don't free buffer0 blocks when it's still in use via buffer fd API#3318nunojsa wants to merge 1 commit into
nunojsa wants to merge 1 commit into
Conversation
…r fd API When a user opens /dev/iio:deviceN to issue IIO_BUFFER_GET_FD_IOCTL for any buffer (including buffer0), the chrdev must be opened and then closed. On close, iio_chrdev_release() unconditionally frees buffer0's mmap blocks via iio_buffer_free_blocks(). This is wrong when buffer0 is actively streaming through its own per-buffer fd — the chrdev close destroys the blocks and kills the stream. Guard the iio_buffer_free_blocks() call by checking buffer0's IIO_BUSY_BIT_POS flag. If buffer0's fd is still open and active, its blocks are managed by the buffer's own fd and will be freed in iio_buffer_chrdev_release() instead. Signed-off-by: Nuno Sá <nuno.sa@analog.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a user opens /dev/iio:deviceN to issue IIO_BUFFER_GET_FD_IOCTL for any buffer (including buffer0), the chrdev must be opened and then closed. On close, iio_chrdev_release() unconditionally frees buffer0's mmap blocks via iio_buffer_free_blocks().
This is wrong when buffer0 is actively streaming through its own per-buffer fd — the chrdev close destroys the blocks and kills the stream.
Guard the iio_buffer_free_blocks() call by checking buffer0's IIO_BUSY_BIT_POS flag. If buffer0's fd is still open and active, its blocks are managed by the buffer's own fd and will be freed in iio_buffer_chrdev_release() instead.
This becomes a problem with multi buffer support when userspace (rightfully) opens the main chardev to get the buffer handle and then closes it again.
PR Type
PR Checklist