From d8c0d5eebb4ac576914daf2f7f0dc241830d3d8d Mon Sep 17 00:00:00 2001 From: Yonghua Huang Date: Tue, 22 Mar 2022 12:05:39 +0300 Subject: [PATCH] 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 --- devicemodel/hw/pci/virtio/virtio_i2c.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devicemodel/hw/pci/virtio/virtio_i2c.c b/devicemodel/hw/pci/virtio/virtio_i2c.c index 955270c16..61f7cccad 100644 --- a/devicemodel/hw/pci/virtio/virtio_i2c.c +++ b/devicemodel/hw/pci/virtio/virtio_i2c.c @@ -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; }