dm: update virtio-i2c bus counter when device is deinit

i2c bus counter 'acpi_i2c_adapter_num' shall be updated
 when virtio-i2c device is de-initialized, else in user VM
 reboot case, this global counter will not be reset and
 keep the value last user VM boot, which is not expected
 and cause iasl(building ACPI data) program crash finally
 because the i2c device name space overflow.

Tracked-On: #7208
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang 2022-03-22 12:05:39 +03:00 committed by acrnsi-robot
parent 05cc6664ca
commit d8c0d5eebb
1 changed files with 2 additions and 0 deletions

View File

@ -838,6 +838,8 @@ virtio_i2c_deinit(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
pthread_mutex_destroy(&vi2c->req_mtx);
pthread_mutex_destroy(&vi2c->mtx);
virtio_i2c_reset(vi2c);
acpi_i2c_adapter_num--;
assert(acpi_i2c_adapter_num >= 0);
free(vi2c);
dev->arg = NULL;
}