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

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>
This commit is contained in:
Li Fei1 2021-05-10 16:51:14 +08:00 committed by wenlingz
parent 6d69058a9d
commit 5939c1afba

View File

@ -248,13 +248,13 @@ unregister_mem_int(struct mmio_rb_tree *rbt, struct mem_range *memp)
/* flush Per-VM cache */ /* flush Per-VM cache */
if (mmio_hint == entry) if (mmio_hint == entry)
mmio_hint = NULL; mmio_hint = NULL;
if (entry)
free(entry);
} }
} }
pthread_rwlock_unlock(&mmio_rwlock); pthread_rwlock_unlock(&mmio_rwlock);
if (entry)
free(entry);
return err; return err;
} }