Module Name: src
Committed By: msaitoh
Date: Thu Jun 26 03:28:47 UTC 2014
Modified Files:
src/sys/compat/netbsd32 [netbsd-6]: netbsd32_netbsd.c
Log Message:
Pull up following revision(s) (requested by maxv in ticket #1084):
sys/compat/netbsd32/netbsd32_netbsd.c rev. 1.187
Fix cases where count <= 0 (thanks to Maxime Villard for raising this).
To generate a diff of this commit:
cvs rdiff -u -r1.179.2.1 -r1.179.2.2 \
src/sys/compat/netbsd32/netbsd32_netbsd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/compat/netbsd32/netbsd32_netbsd.c
diff -u src/sys/compat/netbsd32/netbsd32_netbsd.c:1.179.2.1 src/sys/compat/netbsd32/netbsd32_netbsd.c:1.179.2.2
--- src/sys/compat/netbsd32/netbsd32_netbsd.c:1.179.2.1 Tue Mar 18 08:09:46 2014
+++ src/sys/compat/netbsd32/netbsd32_netbsd.c Thu Jun 26 03:28:47 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_netbsd.c,v 1.179.2.1 2014/03/18 08:09:46 msaitoh Exp $ */
+/* $NetBSD: netbsd32_netbsd.c,v 1.179.2.2 2014/06/26 03:28:47 msaitoh Exp $ */
/*
* Copyright (c) 1998, 2001, 2008 Matthew R. Green
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.179.2.1 2014/03/18 08:09:46 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.179.2.2 2014/06/26 03:28:47 msaitoh Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
@@ -1740,6 +1740,12 @@ netbsd32_swapctl_stats(struct lwp *l, st
int i, error = 0;
size_t ksep_len;
+ if (count < 0)
+ return EINVAL;
+
+ if (count == 0 || uvmexp.nswapdev == 0)
+ return 0;
+
/* Make sure userland cannot exhaust kernel memory */
if ((size_t)count > (size_t)uvmexp.nswapdev)
count = uvmexp.nswapdev;
@@ -1751,9 +1757,6 @@ netbsd32_swapctl_stats(struct lwp *l, st
uvm_swap_stats(SWAP_STATS, ksep, count, retval);
count = *retval;
- if (count < 1)
- goto out;
-
for (i = 0; i < count; i++) {
se32.se_dev = ksep[i].se_dev;
se32.se_flags = ksep[i].se_flags;
@@ -1768,8 +1771,6 @@ netbsd32_swapctl_stats(struct lwp *l, st
break;
}
-
-out:
kmem_free(ksep, ksep_len);
return error;