diff options
Diffstat (limited to 'usr/src/uts/common/os/vmem.c')
-rw-r--r-- | usr/src/uts/common/os/vmem.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/usr/src/uts/common/os/vmem.c b/usr/src/uts/common/os/vmem.c index 056deed958..6946a35a38 100644 --- a/usr/src/uts/common/os/vmem.c +++ b/usr/src/uts/common/os/vmem.c @@ -25,6 +25,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. + * Copyright (c) 2012, Joyent, Inc. All rights reserved. */ /* @@ -1065,6 +1066,21 @@ do_alloc: aneeded = MAX(size + aphase, vmp->vm_min_import); asize = P2ROUNDUP(aneeded, aquantum); + if (asize < size) { + /* + * The rounding induced overflow; return NULL + * if we are permitted to fail the allocation + * (and explicitly panic if we aren't). + */ + if ((vmflag & VM_NOSLEEP) && + !(vmflag & VM_PANIC)) { + mutex_exit(&vmp->vm_lock); + return (NULL); + } + + panic("vmem_xalloc(): size overflow"); + } + /* * Determine how many segment structures we'll consume. * The calculation must be precise because if we're |