vfs server: fix dangling alloc on watch failure

This patch reverts the vfs-watch-handle creation whenever the subsequent
allocation of the VFS server's 'Watch' object fails. This can happen
when the session RAM or cap quota is depleted.

Fixes #4472
This commit is contained in:
Norman Feske 2022-04-07 14:53:05 +02:00 committed by Christian Helmuth
parent df1767b784
commit 79279b93fb

View File

@ -590,10 +590,16 @@ class Vfs_server::Session_component : private Session_resources,
throw Out_of_caps(); throw Out_of_caps();
} }
Node &node = *new (_alloc) try {
Watch_node(_node_space, path_str, *vfs_handle, *this); Node &node = *new (_alloc)
Watch_node(_node_space, path_str, *vfs_handle, *this);
return Watch_handle { node.id().value }; return Watch_handle { node.id().value };
}
catch (...) {
vfs_handle->close();
throw;
}
} }
void close(Node_handle handle) override void close(Node_handle handle) override