dm: rb: only free rb_entry when we remove this entry from the

Only free rb_entry when we remove this entry from the rb tree, otherwise, a
page fault would trigger when next rb itreation would access the freed rb_entry.

Tracked-On: #6056
Signed-off-by: Li Fei1 <fei1.li@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang 2021-07-01 16:29:27 +08:00 committed by wenlingz
parent 2e08f32e7a
commit 65a957dff8

View File

@ -346,12 +346,12 @@ unregister_mem(struct mem_range *memp)
/* flush Per-VM cache */
if (mmio_hint == entry)
mmio_hint = NULL;
if (entry)
free(entry);
}
pthread_rwlock_unlock(&mmio_rwlock);
if (entry)
free(entry);
return err;
}