Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Correct sizes to pass uvm_km_free(9) in error paths.
details: https://anonhg.NetBSD.org/src/rev/fa6f9c777974
branches: trunk
changeset: 767777:fa6f9c777974
user: uebayasi <uebayasi%NetBSD.org@localhost>
date: Sat Jul 30 06:19:02 2011 +0000
description:
Correct sizes to pass uvm_km_free(9) in error paths.
diffstat:
sys/kern/sysv_msg.c | 13 +++++++------
sys/kern/sysv_sem.c | 13 +++++++------
sys/kern/sysv_shm.c | 13 +++++++------
3 files changed, 21 insertions(+), 18 deletions(-)
diffs (144 lines):
diff -r 7ff85b5cc779 -r fa6f9c777974 sys/kern/sysv_msg.c
--- a/sys/kern/sysv_msg.c Sat Jul 30 05:24:16 2011 +0000
+++ b/sys/kern/sysv_msg.c Sat Jul 30 06:19:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysv_msg.c,v 1.61 2009/01/28 00:59:03 njoly Exp $ */
+/* $NetBSD: sysv_msg.c,v 1.62 2011/07/30 06:19:02 uebayasi Exp $ */
/*-
* Copyright (c) 1999, 2006, 2007 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.61 2009/01/28 00:59:03 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_msg.c,v 1.62 2011/07/30 06:19:02 uebayasi Exp $");
#define SYSVMSG
@@ -116,8 +116,8 @@
ALIGN(msginfo.msgseg * sizeof(struct msgmap)) +
ALIGN(msginfo.msgtql * sizeof(struct __msg)) +
ALIGN(msginfo.msgmni * sizeof(kmsq_t));
- v = uvm_km_alloc(kernel_map, round_page(sz), 0,
- UVM_KMF_WIRED|UVM_KMF_ZERO);
+ sz = round_page(sz);
+ v = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
if (v == 0)
panic("sysv_msg: cannot allocate memory");
msgpool = (void *)v;
@@ -176,8 +176,8 @@
ALIGN(newmsgseg * sizeof(struct msgmap)) +
ALIGN(msginfo.msgtql * sizeof(struct __msg)) +
ALIGN(newmsgmni * sizeof(kmsq_t));
- v = uvm_km_alloc(kernel_map, round_page(sz), 0,
- UVM_KMF_WIRED|UVM_KMF_ZERO);
+ sz = round_page(sz);
+ v = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
if (v == 0)
return ENOMEM;
@@ -339,6 +339,7 @@
ALIGN(msginfo.msgseg * sizeof(struct msgmap)) +
ALIGN(msginfo.msgtql * sizeof(struct __msg)) +
ALIGN(msginfo.msgmni * sizeof(kmsq_t));
+ sz = round_page(sz);
for (i = 0; i < msginfo.msgmni; i++)
cv_destroy(&msqs[i].msq_cv);
diff -r 7ff85b5cc779 -r fa6f9c777974 sys/kern/sysv_sem.c
--- a/sys/kern/sysv_sem.c Sat Jul 30 05:24:16 2011 +0000
+++ b/sys/kern/sysv_sem.c Sat Jul 30 06:19:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysv_sem.c,v 1.87 2011/05/13 22:16:44 rmind Exp $ */
+/* $NetBSD: sysv_sem.c,v 1.88 2011/07/30 06:19:02 uebayasi Exp $ */
/*-
* Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.87 2011/05/13 22:16:44 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_sem.c,v 1.88 2011/07/30 06:19:02 uebayasi Exp $");
#define SYSVSEM
@@ -106,8 +106,8 @@
ALIGN(seminfo.semmns * sizeof(struct __sem)) +
ALIGN(seminfo.semmni * sizeof(kcondvar_t)) +
ALIGN(seminfo.semmnu * seminfo.semusz);
- v = uvm_km_alloc(kernel_map, round_page(sz), 0,
- UVM_KMF_WIRED|UVM_KMF_ZERO);
+ sz = round_page(sz);
+ v = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
if (v == 0)
panic("sysv_sem: cannot allocate memory");
sema = (void *)v;
@@ -150,8 +150,8 @@
ALIGN(newsemmns * sizeof(struct __sem)) +
ALIGN(newsemmni * sizeof(kcondvar_t)) +
ALIGN(newsemmnu * seminfo.semusz);
- v = uvm_km_alloc(kernel_map, round_page(sz), 0,
- UVM_KMF_WIRED|UVM_KMF_ZERO);
+ sz = round_page(sz);
+ v = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
if (v == 0)
return ENOMEM;
@@ -251,6 +251,7 @@
ALIGN(seminfo.semmns * sizeof(struct __sem)) +
ALIGN(seminfo.semmni * sizeof(kcondvar_t)) +
ALIGN(seminfo.semmnu * seminfo.semusz);
+ sz = round_page(sz);
/* Set the pointers and update the new values */
sema = new_sema;
diff -r 7ff85b5cc779 -r fa6f9c777974 sys/kern/sysv_shm.c
--- a/sys/kern/sysv_shm.c Sat Jul 30 05:24:16 2011 +0000
+++ b/sys/kern/sysv_shm.c Sat Jul 30 06:19:02 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysv_shm.c,v 1.120 2011/06/12 03:35:56 rmind Exp $ */
+/* $NetBSD: sysv_shm.c,v 1.121 2011/07/30 06:19:02 uebayasi Exp $ */
/*-
* Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -61,7 +61,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.120 2011/06/12 03:35:56 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysv_shm.c,v 1.121 2011/07/30 06:19:02 uebayasi Exp $");
#define SYSVSHM
@@ -877,8 +877,8 @@
/* Allocate new memory area */
sz = ALIGN(newshmni * sizeof(struct shmid_ds)) +
ALIGN(newshmni * sizeof(kcondvar_t));
- v = uvm_km_alloc(kernel_map, round_page(sz), 0,
- UVM_KMF_WIRED|UVM_KMF_ZERO);
+ sz = round_page(sz);
+ v = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
if (v == 0)
return ENOMEM;
@@ -936,6 +936,7 @@
sz = ALIGN(oldshmni * sizeof(struct shmid_ds)) +
ALIGN(oldshmni * sizeof(kcondvar_t));
+ sz = round_page(sz);
uvm_km_free(kernel_map, (vaddr_t)oldshmsegs, sz, UVM_KMF_WIRED);
return 0;
@@ -954,8 +955,8 @@
/* Allocate the wired memory for our structures */
sz = ALIGN(shminfo.shmmni * sizeof(struct shmid_ds)) +
ALIGN(shminfo.shmmni * sizeof(kcondvar_t));
- v = uvm_km_alloc(kernel_map, round_page(sz), 0,
- UVM_KMF_WIRED|UVM_KMF_ZERO);
+ sz = round_page(sz);
+ v = uvm_km_alloc(kernel_map, sz, 0, UVM_KMF_WIRED|UVM_KMF_ZERO);
if (v == 0)
panic("sysv_shm: cannot allocate memory");
shmsegs = (void *)v;
Home |
Main Index |
Thread Index |
Old Index