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:
parent
88161bfca5
commit
dfa6a43744
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue