Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,16 @@
kfree(ib);
clear_bit(IIO_BUSY_BIT_POS, &iio_dev_opaque->flags);
#ifdef CONFIG_IIO_DMA_BUF_MMAP_LEGACY
if (indio_dev->buffer)
/*
* Only free buffer0 blocks if it was being used through the legacy
* chrdev API. If buffer0 was opened through the new per-buffer fd API
* (IIO_BUFFER_GET_FD_IOCTL), its blocks are managed by the buffer's
* own fd and will be freed in iio_buffer_chrdev_release() instead.
* Without this check, opening any other buffer's fd (which requires
* opening and closing /dev/iio:deviceN) would destroy buffer0's
* blocks and kill an active stream.
*/
if (indio_dev->buffer && !test_bit(IIO_BUSY_BIT_POS, &indio_dev->buffer->flags))
iio_buffer_free_blocks(indio_dev->buffer);
#endif
iio_device_put(indio_dev);
Expand Down Expand Up @@ -2222,7 +2231,7 @@
mutex_lock(&iio_dev_opaque->mlock);

if (iio_buffer_enabled(indio_dev))
return 0;

Check warning on line 2234 in drivers/iio/industrialio-core.c

View workflow job for this annotation

GitHub Actions / checks / checks

coccicheck: 2-8 preceding lock on line 2231

mutex_unlock(&iio_dev_opaque->mlock);
return -EBUSY;
Expand Down
Loading