Skip to content

Commit

Permalink
core: pager: refactored to fix NULL dereferencing
Browse files Browse the repository at this point in the history
assert not NULL before dereferencing in tee_pager_add_core_area().

Signed-off-by: Sander Visser <[email protected]>
Reviewed-by: Jens Wiklander <[email protected]>
Reviewed-by: Etienne Carriere <[email protected]>
  • Loading branch information
sander-visser authored and jforissier committed Jun 29, 2020
1 parent b2b2762 commit 3f37fff
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/arch/arm/mm/tee_pager.c
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,12 @@ void tee_pager_add_core_area(vaddr_t base, enum tee_pager_area_type type,
uint32_t flags = 0;
size_t fobj_pgoffs = 0;
vaddr_t b = base;
size_t s = fobj->num_pages * SMALL_PAGE_SIZE;
size_t s = 0;
size_t s2 = 0;

assert(fobj);
s = fobj->num_pages * SMALL_PAGE_SIZE;

DMSG("0x%" PRIxPTR " - 0x%" PRIxPTR " : type %d", base, base + s, type);

if (base & SMALL_PAGE_MASK || !s) {
Expand All @@ -554,9 +557,6 @@ void tee_pager_add_core_area(vaddr_t base, enum tee_pager_area_type type,
panic();
}

if (!fobj)
panic();

while (s) {
s2 = MIN(CORE_MMU_PGDIR_SIZE - (b & CORE_MMU_PGDIR_MASK), s);
area = calloc(1, sizeof(*area));
Expand Down

0 comments on commit 3f37fff

Please sign in to comment.