Fix OOM paths in extent_grow_retained().

This commit is contained in:
Jason Evans 2017-05-25 18:15:41 -07:00
parent d5ef5ae934
commit a16114866a

View File

@ -1046,10 +1046,15 @@ extent_grow_retained(tsdn_t *tsdn, arena_t *arena,
extent_init(extent, arena, ptr, alloc_size, false, NSIZES,
arena_extent_sn_next(arena), extent_state_active, zeroed,
committed);
if (ptr == NULL || extent_register_no_gdump_add(tsdn, extent)) {
if (ptr == NULL) {
extent_dalloc(tsdn, arena, extent);
return NULL;
}
if (extent_register_no_gdump_add(tsdn, extent)) {
extents_leak(tsdn, arena, r_extent_hooks,
&arena->extents_retained, extent);
return NULL;
}
size_t leadsize = ALIGNMENT_CEILING((uintptr_t)ptr,
PAGE_CEILING(alignment)) - (uintptr_t)ptr;
@ -1070,7 +1075,8 @@ extent_grow_retained(tsdn_t *tsdn, arena_t *arena,
leadsize, NSIZES, false, esize + trailsize, szind, slab);
if (extent == NULL) {
extent_deregister(tsdn, lead);
extents_leak(tsdn, arena, r_extent_hooks, false, lead);
extents_leak(tsdn, arena, r_extent_hooks,
&arena->extents_retained, lead);
return NULL;
}
extent_record(tsdn, arena, r_extent_hooks,