diff --git a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp index c240187cfb..381293805e 100644 --- a/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp +++ b/src/add-ons/kernel/file_systems/bfs/kernel_interface.cpp @@ -113,6 +113,7 @@ iterative_io_finished_hook(void* cookie, io_request* request, status_t status, { Inode* inode = (Inode*)cookie; rw_lock_read_unlock(&inode->Lock()); + put_vnode(inode->GetVolume()->FSVolume(), inode->ID()); return B_OK; } @@ -522,6 +523,12 @@ bfs_io(fs_volume* _volume, fs_vnode* _node, void* _cookie, io_request* request) // We lock the node here and will unlock it in the "finished" hook. rw_lock_read_lock(&inode->Lock()); + // Due to how I/O request notifications work, it is possible that + // some other thread could be notified that the request completed + // before we have a chance to release the read lock. We thus need + // our own reference to the vnode. + acquire_vnode(_volume, inode->ID()); + return do_iterative_fd_io(volume->Device(), request, iterative_io_get_vecs_hook, iterative_io_finished_hook, inode); }