From 02788cedc0b728427a7aeb373cbf37be36d033b1 Mon Sep 17 00:00:00 2001 From: zhangfanfan2 Date: Tue, 3 Nov 2020 11:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F=E3=80=81?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E9=87=8E=E6=8C=87=E9=92=88=E4=BB=A5=E5=8F=8A?= =?UTF-8?q?=E7=AB=9E=E6=80=81=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/base/vm/los_vm_filemap.c | 2 ++ kernel/base/vm/los_vm_map.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/base/vm/los_vm_filemap.c b/kernel/base/vm/los_vm_filemap.c index e5f6483e..8b88e85d 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 c4271ab0..56abd261 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: