fs/mmap: fix wrong return value check

while iterate throuh all mapping memory to munmap and release,
the last entry is NUlL.
We need differentiate the case with invald entry at the first.

The fix is to pass ltp shm related cases.

Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This commit is contained in:
fangxinyong 2023-06-08 17:41:46 +08:00 committed by Xiang Xiao
parent 88161bfca5
commit dfa6a43744
1 changed files with 13 additions and 8 deletions

View File

@ -60,22 +60,27 @@ static int file_munmap_(FAR void *start, size_t length, bool kernel)
ret = mm_map_lock();
if (ret == OK)
{
while (ret == OK && (entry = mm_map_find(mm, start, length)))
entry = mm_map_find(mm, start, length);
/* If entry don't find, the start and length is invalid. */
if (entry == NULL)
{
ret = -EINVAL;
goto unlock;
}
do
{
DEBUGASSERT(entry->munmap);
ret = entry->munmap(group, entry, start, length);
}
while (ret == OK && (entry = mm_map_find(mm, start, length)));
unlock:
mm_map_unlock();
}
/* If entry don't find, the start and length is invalid. */
if (entry == NULL)
{
return -EINVAL;
}
return ret;
}