From ca5bdd2ac3e473e9b082c44c2870f446b96323a2 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 15 Jun 2020 09:20:46 +0000 Subject: crosvm: fix balloon and USB sockets 5bd2e7f606b726b598fdc26fe26a9b4029fab6d3 introduced queued_device_reqs to accomodate devices that are not ready to receive messages until they are activated in response to an event. But, devices that are ready immediately were not added to the map. When an event came in to one of these sockets (balloon and USB), the socket file descriptor would be looked up in queued_device_reqs, and crosvm would then crash because it wouldn't be found. The correct behaviour, which this patch implements, is to treat a missing entry the same as a Ready entry. An alternative would have been to add all other sockets to queued_device_reqs, and set them to Ready up front, but that would be more difficult to keep up to date than having a default. This way, only devices that need queueing need to be added to queued_device_reqs. Fixes: 5bd2e7f606b726b598fdc26fe26a9b4029fab6d3 --- src/linux.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/linux.rs') diff --git a/src/linux.rs b/src/linux.rs index ccd7d88..d332780 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -2189,9 +2189,9 @@ fn run_control( &usb_control_socket, ); - match device_socket.map(|s| { - queued_device_reqs.get_mut(&s.as_raw_fd()).unwrap() - }) { + match device_socket + .and_then(|s| queued_device_reqs.get_mut(&s.as_raw_fd())) + { None | Some(DeviceStatus::Ready) => { match do_vm_request( request, -- cgit 1.4.1