uipc_sem.c (109084) | uipc_sem.c (109623) |
---|---|
1/* 2 * Copyright (c) 2002 Alfred Perlstein <alfred@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/* 2 * Copyright (c) 2002 Alfred Perlstein <alfred@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/kern/uipc_sem.c 109084 2003-01-10 23:13:16Z alfred $ | 26 * $FreeBSD: head/sys/kern/uipc_sem.c 109623 2003-01-21 08:56:16Z alfred $ |
27 */ 28 29#include "opt_posix.h" 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/sysproto.h> 34#include <sys/kernel.h> --- 148 unchanged lines hidden (view full) --- 183 size_t len; 184 int error; 185 186 DP(("sem_create\n")); 187 p = td->td_proc; 188 uc = p->p_ucred; 189 if (value > SEM_VALUE_MAX) 190 return (EINVAL); | 27 */ 28 29#include "opt_posix.h" 30 31#include <sys/param.h> 32#include <sys/systm.h> 33#include <sys/sysproto.h> 34#include <sys/kernel.h> --- 148 unchanged lines hidden (view full) --- 183 size_t len; 184 int error; 185 186 DP(("sem_create\n")); 187 p = td->td_proc; 188 uc = p->p_ucred; 189 if (value > SEM_VALUE_MAX) 190 return (EINVAL); |
191 ret = malloc(sizeof(*ret), M_SEM, M_WAITOK | M_ZERO); | 191 ret = malloc(sizeof(*ret), M_SEM, M_ZERO); |
192 if (name != NULL) { 193 len = strlen(name); 194 if (len > SEM_MAX_NAMELEN) { 195 free(ret, M_SEM); 196 return (ENAMETOOLONG); 197 } 198 /* name must start with a '/' but not contain one. */ 199 if (*name != '/' || len < 2 || index(name + 1, '/') != NULL) { 200 free(ret, M_SEM); 201 return (EINVAL); 202 } | 192 if (name != NULL) { 193 len = strlen(name); 194 if (len > SEM_MAX_NAMELEN) { 195 free(ret, M_SEM); 196 return (ENAMETOOLONG); 197 } 198 /* name must start with a '/' but not contain one. */ 199 if (*name != '/' || len < 2 || index(name + 1, '/') != NULL) { 200 free(ret, M_SEM); 201 return (EINVAL); 202 } |
203 ret->ks_name = malloc(len + 1, M_SEM, M_WAITOK); | 203 ret->ks_name = malloc(len + 1, M_SEM, 0); |
204 strcpy(ret->ks_name, name); 205 } else { 206 ret->ks_name = NULL; 207 } 208 ret->ks_mode = mode; 209 ret->ks_value = value; 210 ret->ks_ref = 1; 211 ret->ks_waiters = 0; --- 287 unchanged lines hidden (view full) --- 499 500static void 501sem_enter(p, ks) 502 struct proc *p; 503 struct ksem *ks; 504{ 505 struct kuser *ku, *k; 506 | 204 strcpy(ret->ks_name, name); 205 } else { 206 ret->ks_name = NULL; 207 } 208 ret->ks_mode = mode; 209 ret->ks_value = value; 210 ret->ks_ref = 1; 211 ret->ks_waiters = 0; --- 287 unchanged lines hidden (view full) --- 499 500static void 501sem_enter(p, ks) 502 struct proc *p; 503 struct ksem *ks; 504{ 505 struct kuser *ku, *k; 506 |
507 ku = malloc(sizeof(*ku), M_SEM, M_WAITOK); | 507 ku = malloc(sizeof(*ku), M_SEM, 0); |
508 ku->ku_pid = p->p_pid; 509 mtx_lock(&sem_lock); 510 k = sem_getuser(p, ks); 511 if (k != NULL) { 512 mtx_unlock(&sem_lock); 513 free(ku, M_TEMP); 514 return; 515 } --- 326 unchanged lines hidden --- | 508 ku->ku_pid = p->p_pid; 509 mtx_lock(&sem_lock); 510 k = sem_getuser(p, ks); 511 if (k != NULL) { 512 mtx_unlock(&sem_lock); 513 free(ku, M_TEMP); 514 return; 515 } --- 326 unchanged lines hidden --- |