Skip to content

Commit

Permalink
[scudo][Fuchsia] Don't assume MapPlatformData::Vmar is valid
Browse files Browse the repository at this point in the history
After https://reviews.llvm.org/D129237, the assumption
that any non-null data contains a valid vmar handle is no
longer true. Generally this code here needs cleanup, but
in the meantime this fixes errors on Fuchsia.

Differential Revision: https://reviews.llvm.org/D129331
  • Loading branch information
abrachet committed Jul 11, 2022
1 parent d0751c9 commit c823cbf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions compiler-rt/lib/scudo/standalone/fuchsia.cpp
Expand Up @@ -57,8 +57,7 @@ void *map(void *Addr, uptr Size, const char *Name, uptr Flags,
if (Flags & MAP_NOACCESS)
return allocateVmar(Size, Data, AllowNoMem);

const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
CHECK_NE(Vmar, ZX_HANDLE_INVALID);
const zx_handle_t Vmar = (Data && Data->Vmar != ZX_HANDLE_INVALID) ? Data->Vmar : _zx_vmar_root_self();

zx_status_t Status;
zx_handle_t Vmo;
Expand Down Expand Up @@ -126,7 +125,7 @@ void unmap(void *Addr, uptr Size, uptr Flags, MapPlatformData *Data) {
CHECK_EQ(_zx_vmar_destroy(Vmar), ZX_OK);
CHECK_EQ(_zx_handle_close(Vmar), ZX_OK);
} else {
const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
const zx_handle_t Vmar = (Data && Data->Vmar != ZX_HANDLE_INVALID) ? Data->Vmar : _zx_vmar_root_self();
const zx_status_t Status =
_zx_vmar_unmap(Vmar, reinterpret_cast<uintptr_t>(Addr), Size);
if (UNLIKELY(Status != ZX_OK))
Expand Down

0 comments on commit c823cbf

Please sign in to comment.