diff --git a/kernel/base/vm/los_vm_filemap.c b/kernel/base/vm/los_vm_filemap.c index e5f6483e00aa643e992d2c3cdd7ecc1fdea31ee7..8b88e85dba06978b6bca31cf0acd53142411493c 100644 --- a/kernel/base/vm/los_vm_filemap.c +++ b/kernel/base/vm/los_vm_filemap.c @@ -751,6 +751,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB) space = processCB->vmSpace; if (space != NULL) { + (VOID)LOS_MuxAcquire(&space->regionMux); /* free the regions associated with filep */ RB_SCAN_SAFE(&space->regionRbTree, pstRbNode, pstRbNodeTmp) region = (LosVmMapRegion *)pstRbNode; @@ -764,6 +765,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB) } } RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNode, pstRbNodeTmp) + (VOID)LOS_MuxRelease(&space->regionMux); } } #endif diff --git a/kernel/base/vm/los_vm_map.c b/kernel/base/vm/los_vm_map.c index c4271ab02289752273a1550590a5bc0ba9f1e21b..56abd2618f95ee3755e6bde049a4a90789361449 100644 --- a/kernel/base/vm/los_vm_map.c +++ b/kernel/base/vm/los_vm_map.c @@ -698,7 +698,7 @@ STATUS_T OsVmRegionAdjust(LosVmSpace *space, VADDR_T newRegionStart, size_t size } } - region = LOS_RegionFind(space, nextRegionBase); + region = LOS_RegionFind(space, nextRegionBase - 1); if ((region != NULL) && (nextRegionBase < LOS_RegionEndAddr(region))) { newRegion = OsVmRegionSplit(region, nextRegionBase); if (newRegion == NULL) { @@ -726,6 +726,9 @@ STATUS_T OsRegionsRemove(LosVmSpace *space, VADDR_T regionBase, size_t size) RB_SCAN_SAFE(&space->regionRbTree, pstRbNodeTemp, pstRbNodeNext) regionTemp = (LosVmMapRegion *)pstRbNodeTemp; + if (regionTemp->range.base > regionEnd) { + break; + } if (regionBase <= regionTemp->range.base && regionEnd >= LOS_RegionEndAddr(regionTemp)) { status = LOS_RegionFree(space, regionTemp); if (status != LOS_OK) { @@ -734,9 +737,6 @@ STATUS_T OsRegionsRemove(LosVmSpace *space, VADDR_T regionBase, size_t size) } } - if (regionTemp->range.base > regionEnd) { - break; - } RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNodeTemp, pstRbNodeNext) ERR_REGION_SPLIT: