diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/uts/common/vm/vm_swap.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/usr/src/uts/common/vm/vm_swap.c b/usr/src/uts/common/vm/vm_swap.c index 1a28c04357..2a008e114b 100644 --- a/usr/src/uts/common/vm/vm_swap.c +++ b/usr/src/uts/common/vm/vm_swap.c @@ -18,6 +18,11 @@ * * CDDL HEADER END */ + +/* + * Copyright 2015 Joyent, Inc. + */ + /* * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved. */ @@ -625,7 +630,18 @@ swapctl(int sc_cmd, void *sc_arg, int *rv) return (0); } beginning: + mutex_enter(&swapinfo_lock); tmp_nswapfiles = nswapfiles; + mutex_exit(&swapinfo_lock); + + /* + * Return early if there are no swap entries to report: + */ + if (tmp_nswapfiles < 1) { + *rv = 0; + return (0); + } + /* Return an error if not enough space for the whole table. */ if (length < tmp_nswapfiles) return (ENOMEM); @@ -920,7 +936,18 @@ swapctl32(int sc_cmd, void *sc_arg, int *rv) return (0); } beginning: + mutex_enter(&swapinfo_lock); tmp_nswapfiles = nswapfiles; + mutex_exit(&swapinfo_lock); + + /* + * Return early if there are no swap entries to report: + */ + if (tmp_nswapfiles < 1) { + *rv = 0; + return (0); + } + /* Return an error if not enough space for the whole table. */ if (length < tmp_nswapfiles) return (ENOMEM); |