Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/compat/netbsd32 Fix cases where count <= 0 (thanks to Ma...
details: https://anonhg.NetBSD.org/src/rev/af52aca5178b
branches: trunk
changeset: 329225:af52aca5178b
user: manu <manu%NetBSD.org@localhost>
date: Thu May 15 18:25:35 2014 +0000
description:
Fix cases where count <= 0 (thanks to Maxime Villard for raising this)
diffstat:
sys/compat/netbsd32/netbsd32_netbsd.c | 15 ++++++++-------
1 files changed, 8 insertions(+), 7 deletions(-)
diffs (50 lines):
diff -r 9e343d8fad1c -r af52aca5178b sys/compat/netbsd32/netbsd32_netbsd.c
--- a/sys/compat/netbsd32/netbsd32_netbsd.c Thu May 15 17:05:15 2014 +0000
+++ b/sys/compat/netbsd32/netbsd32_netbsd.c Thu May 15 18:25:35 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_netbsd.c,v 1.186 2014/04/30 17:23:45 njoly Exp $ */
+/* $NetBSD: netbsd32_netbsd.c,v 1.187 2014/05/15 18:25:35 manu 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.186 2014/04/30 17:23:45 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_netbsd.c,v 1.187 2014/05/15 18:25:35 manu Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ddb.h"
@@ -1763,6 +1763,12 @@
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;
@@ -1774,9 +1780,6 @@
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;
@@ -1791,8 +1794,6 @@
break;
}
-
-out:
kmem_free(ksep, ksep_len);
return error;
Home |
Main Index |
Thread Index |
Old Index