mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-06-08 01:54:44 +00:00
dm: reduce potential crash caused by LIST_FOREACH
When removing node in list, list_foreach_safe will be safer than LIST_FOREACH. Tracked-On: #3778 Signed-off-by: Junhao Gao <junhao.gao@intel.com> Reviewed-by: Yonghua Huang <yonghua.huang@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
committed by
ACRN System Integration
parent
e6e0e27788
commit
72232daafe
@@ -502,10 +502,10 @@ vmei_del_me_client(struct vmei_me_client *mclient)
|
||||
static void
|
||||
vmei_me_client_destroy_host_clients(struct vmei_me_client *mclient)
|
||||
{
|
||||
struct vmei_host_client *e;
|
||||
struct vmei_host_client *e, *temp;
|
||||
|
||||
pthread_mutex_lock(&mclient->list_mutex);
|
||||
LIST_FOREACH(e, &mclient->connections, list) {
|
||||
list_foreach_safe(e, &mclient->connections, list, temp) {
|
||||
vmei_host_client_put(e);
|
||||
}
|
||||
LIST_INIT(&mclient->connections);
|
||||
@@ -643,10 +643,10 @@ vmei_find_host_client(struct virtio_mei *vmei,
|
||||
|
||||
static void vmei_free_me_clients(struct virtio_mei *vmei)
|
||||
{
|
||||
struct vmei_me_client *e;
|
||||
struct vmei_me_client *e, *temp;
|
||||
|
||||
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_put(e);
|
||||
}
|
||||
LIST_INIT(&vmei->active_clients);
|
||||
@@ -937,7 +937,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;
|
||||
@@ -948,7 +948,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);
|
||||
|
||||
Reference in New Issue
Block a user