diff options
author | Joshua M. Clulow <jmc@joyent.com> | 2015-06-03 21:37:42 +0000 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2017-01-03 22:01:26 -0800 |
commit | e1936e201a9a6139df26cffebf1de54d1ab41369 (patch) | |
tree | 1627a12cf994b613b79a149617801e3c998fb884 /usr/src | |
parent | b8692e0c2f0c23ce751c0af9c1efb4391bfd00f2 (diff) | |
download | illumos-gate-e1936e201a9a6139df26cffebf1de54d1ab41369.tar.gz |
7511 swapctl(SC_LIST) allocation nihilism
Reviewed by: Robert Mustacchi <rm@joyent.com>
Approved by: Richard Lowe <richlowe@richlowe.net>
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); |