mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-06 02:25:23 +00:00
devices: vfio: Fix vfio device initialization missing 'group.add_device_num()'
This fixes a bug introduced by [1] when removing vfio device and
'device_num' is zero.
A panic occured when unplug a vfio device:
[ERROR:src/panic_hook.rs:90] thread 'crosvm_vcpu4' panicked at 'attempt to subtract with overflow', devices/src/vfio.rs:462:9
The variable group.device_num is 0 when subtract. And when initalizes a
vfio device from hot-plugging workflow, 'group.add_device_num()' is
missing.
BUG=b:185084350
TEST=hotplug in and out a vfio-pci device in guest repeatedly
[1]: 7b80554473
Change-Id: I9a039cd15e9f9414a4a0501c64da13be76e59c1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3365212
Reviewed-by: Xiong Y Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
0bbbb688b9
commit
3cde974af0
1 changed files with 1 additions and 0 deletions
|
@ -603,6 +603,7 @@ impl VfioDevice {
|
|||
let name = String::from(name_str);
|
||||
let dev = group.lock().get_device(&name)?;
|
||||
let regions = Self::get_regions(&dev)?;
|
||||
group.lock().add_device_num();
|
||||
let group_descriptor = group.lock().as_raw_descriptor();
|
||||
|
||||
Ok(VfioDevice {
|
||||
|
|
Loading…
Reference in a new issue