提交 c383ba65 编写于 作者: O openharmony_ci 提交者: Gitee

!28 【轻量级 PR】:内存泄漏、访问野指针以及竞态问题修复。

Merge pull request !28 from zhangfanfan2/N/A
......@@ -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
......
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册