[...]Let's add a comment documenting that.
It is intended, yes. You want to release the dma_buf_attachment that's+ priv = attach->importer_priv;Is this intended? Looks suspicious...
+ list_del_init(&priv->entry);
+
+ iio_buffer_dmabuf_put(attach);
+ iio_buffer_dmabuf_put(attach);
+
created in iio_buffer_attach_dmabuf(), and you need to call
iio_buffer_find_attachment() to get a pointer to it, which also gets a
second reference - so it needs to unref twice.