内存泄漏、访问野指针以及竞态问题修复。

This commit is contained in:
zhangfanfan2 2020-11-03 11:20:09 +08:00 committed by Gitee
parent 67a9c7b8b5
commit 02788cedc0
2 changed files with 6 additions and 4 deletions

View File

@ -751,6 +751,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB)
space = processCB->vmSpace; space = processCB->vmSpace;
if (space != NULL) { if (space != NULL) {
(VOID)LOS_MuxAcquire(&space->regionMux);
/* free the regions associated with filep */ /* free the regions associated with filep */
RB_SCAN_SAFE(&space->regionRbTree, pstRbNode, pstRbNodeTmp) RB_SCAN_SAFE(&space->regionRbTree, pstRbNode, pstRbNodeTmp)
region = (LosVmMapRegion *)pstRbNode; region = (LosVmMapRegion *)pstRbNode;
@ -764,6 +765,7 @@ VOID OsVmmFileRegionFree(struct file *filep, LosProcessCB *processCB)
} }
} }
RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNode, pstRbNodeTmp) RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNode, pstRbNodeTmp)
(VOID)LOS_MuxRelease(&space->regionMux);
} }
} }
#endif #endif

View File

@ -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))) { if ((region != NULL) && (nextRegionBase < LOS_RegionEndAddr(region))) {
newRegion = OsVmRegionSplit(region, nextRegionBase); newRegion = OsVmRegionSplit(region, nextRegionBase);
if (newRegion == NULL) { 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) RB_SCAN_SAFE(&space->regionRbTree, pstRbNodeTemp, pstRbNodeNext)
regionTemp = (LosVmMapRegion *)pstRbNodeTemp; regionTemp = (LosVmMapRegion *)pstRbNodeTemp;
if (regionTemp->range.base > regionEnd) {
break;
}
if (regionBase <= regionTemp->range.base && regionEnd >= LOS_RegionEndAddr(regionTemp)) { if (regionBase <= regionTemp->range.base && regionEnd >= LOS_RegionEndAddr(regionTemp)) {
status = LOS_RegionFree(space, regionTemp); status = LOS_RegionFree(space, regionTemp);
if (status != LOS_OK) { 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) RB_SCAN_SAFE_END(&space->regionRbTree, pstRbNodeTemp, pstRbNodeNext)
ERR_REGION_SPLIT: ERR_REGION_SPLIT: