Module Name:    src
Committed By:   uebayasi
Date:           Sat Jul 30 06:19:02 UTC 2011

Modified Files:
        src/sys/kern: sysv_msg.c sysv_sem.c sysv_shm.c

Log Message:
Correct sizes to pass uvm_km_free(9) in error paths.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/kern/sysv_msg.c
cvs rdiff -u -r1.87 -r1.88 src/sys/kern/sysv_sem.c
cvs rdiff -u -r1.120 -r1.121 src/sys/kern/sysv_shm.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/kern/sysv_msg.c
diff -u src/sys/kern/sysv_msg.c:1.61 src/sys/kern/sysv_msg.c:1.62
--- src/sys/kern/sysv_msg.c:1.61	Wed Jan 28 00:59:03 2009
+++ src/sys/kern/sysv_msg.c	Sat Jul 30 06:19:02 2011
@@ -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);

Index: src/sys/kern/sysv_sem.c
diff -u src/sys/kern/sysv_sem.c:1.87 src/sys/kern/sysv_sem.c:1.88
--- src/sys/kern/sysv_sem.c:1.87	Fri May 13 22:16:44 2011
+++ src/sys/kern/sysv_sem.c	Sat Jul 30 06:19:02 2011
@@ -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;

Index: src/sys/kern/sysv_shm.c
diff -u src/sys/kern/sysv_shm.c:1.120 src/sys/kern/sysv_shm.c:1.121
--- src/sys/kern/sysv_shm.c:1.120	Sun Jun 12 03:35:56 2011
+++ src/sys/kern/sysv_shm.c	Sat Jul 30 06:19:02 2011
@@ -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;

Reply via email to