summary refs log tree commit diff
path: root/src/linux.rs
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-06-15 09:20:46 +0000
committerAlyssa Ross <hi@alyssa.is>2020-06-15 09:20:46 +0000
commitca5bdd2ac3e473e9b082c44c2870f446b96323a2 (patch)
treeff742f442206c8679c56935b4a51821f61dfcc78 /src/linux.rs
parent5bd2e7f606b726b598fdc26fe26a9b4029fab6d3 (diff)
downloadcrosvm-ca5bdd2ac3e473e9b082c44c2870f446b96323a2.tar
crosvm-ca5bdd2ac3e473e9b082c44c2870f446b96323a2.tar.gz
crosvm-ca5bdd2ac3e473e9b082c44c2870f446b96323a2.tar.bz2
crosvm-ca5bdd2ac3e473e9b082c44c2870f446b96323a2.tar.lz
crosvm-ca5bdd2ac3e473e9b082c44c2870f446b96323a2.tar.xz
crosvm-ca5bdd2ac3e473e9b082c44c2870f446b96323a2.tar.zst
crosvm-ca5bdd2ac3e473e9b082c44c2870f446b96323a2.zip
crosvm: fix balloon and USB sockets HEAD master
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
Diffstat (limited to 'src/linux.rs')
-rw-r--r--src/linux.rs6
1 files changed, 3 insertions, 3 deletions
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,