diff --git a/devicemodel/hw/pci/gsi_sharing.c b/devicemodel/hw/pci/gsi_sharing.c index 8a92703a8..ccac1fd1d 100644 --- a/devicemodel/hw/pci/gsi_sharing.c +++ b/devicemodel/hw/pci/gsi_sharing.c @@ -13,6 +13,7 @@ #include #include "pci_core.h" +#include "mevent.h" #define MAX_DEV_PER_GSI 4 @@ -117,7 +118,7 @@ create_gsi_sharing_groups(void) uint8_t gsi; char *dev_name; int i, error, msi_support; - struct gsi_sharing_group *group = NULL; + struct gsi_sharing_group *group = NULL, *temp = NULL; error = pciaccess_init(); if (error < 0) @@ -144,7 +145,7 @@ create_gsi_sharing_groups(void) * clean up gsg_head - the list for gsi_sharing_group * delete the element without gsi sharing condition (shared_dev_num < 2) */ - LIST_FOREACH(group, &gsg_head, gsg_list) { + list_foreach_safe(group, &gsg_head, gsg_list, temp) { if (group->shared_dev_num < 2) { LIST_REMOVE(group, gsg_list); free(group); @@ -181,7 +182,7 @@ update_pt_info(uint16_t phys_bdf) int check_gsi_sharing_violation(void) { - struct gsi_sharing_group *group; + struct gsi_sharing_group *group, *temp; int i, error, violation; error = 0; @@ -226,7 +227,7 @@ check_gsi_sharing_violation(void) } /* destroy the gsg_head after all the checks have been done */ - LIST_FOREACH(group, &gsg_head, gsg_list) { + list_foreach_safe(group, &gsg_head, gsg_list, temp) { LIST_REMOVE(group, gsg_list); free(group); } diff --git a/devicemodel/hw/pci/virtio/virtio_mei.c b/devicemodel/hw/pci/virtio/virtio_mei.c index f49dc62bf..8eae6487b 100644 --- a/devicemodel/hw/pci/virtio/virtio_mei.c +++ b/devicemodel/hw/pci/virtio/virtio_mei.c @@ -942,7 +942,7 @@ static void vmei_virtual_fw_reset(struct virtio_mei *vmei) { DPRINTF("Firmware reset\n"); - struct vmei_me_client *e; + struct vmei_me_client *e, *temp; vmei_set_status(vmei, VMEI_STS_RESET); vmei->config->hw_ready = 0; @@ -953,7 +953,7 @@ vmei_virtual_fw_reset(struct virtio_mei *vmei) /* disconnect all */ pthread_mutex_lock(&vmei->list_mutex); - LIST_FOREACH(e, &vmei->active_clients, list) { + list_foreach_safe(e, &vmei->active_clients, list, temp) { vmei_me_client_destroy_host_clients(e); } pthread_mutex_unlock(&vmei->list_mutex);