mutex_owned, rw_read_held, rw_write_held, rw_lock_held: check for a NULL

pointer.
This commit is contained in:
ad 2008-04-22 14:46:35 +00:00
parent 73d529c226
commit ebca8ee832
2 changed files with 12 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_mutex.c,v 1.34 2008/04/11 15:28:34 ad Exp $ */
/* $NetBSD: kern_mutex.c,v 1.35 2008/04/22 14:46:35 ad Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -47,7 +47,7 @@
#define __MUTEX_PRIVATE
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.34 2008/04/11 15:28:34 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.35 2008/04/22 14:46:35 ad Exp $");
#include "opt_multiprocessor.h"
@ -816,6 +816,8 @@ int
mutex_owned(kmutex_t *mtx)
{
if (mtx == NULL)
return 0;
if (MUTEX_ADAPTIVE_P(mtx))
return MUTEX_OWNER(mtx->mtx_owner) == (uintptr_t)curlwp;
#ifdef FULL

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_rwlock.c,v 1.20 2008/04/11 14:55:51 ad Exp $ */
/* $NetBSD: kern_rwlock.c,v 1.21 2008/04/22 14:46:35 ad Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@ -45,7 +45,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.20 2008/04/11 14:55:51 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.21 2008/04/22 14:46:35 ad Exp $");
#include "opt_multiprocessor.h"
@ -727,7 +727,8 @@ rw_read_held(krwlock_t *rw)
if (panicstr != NULL)
return 1;
if (rw == NULL)
return 0;
owner = rw->rw_owner;
return (owner & RW_WRITE_LOCKED) == 0 && (owner & RW_THREAD) != 0;
}
@ -745,7 +746,8 @@ rw_write_held(krwlock_t *rw)
if (panicstr != NULL)
return 1;
if (rw == NULL)
return 0;
return (rw->rw_owner & (RW_WRITE_LOCKED | RW_THREAD)) ==
(RW_WRITE_LOCKED | (uintptr_t)curlwp);
}
@ -763,7 +765,8 @@ rw_lock_held(krwlock_t *rw)
if (panicstr != NULL)
return 1;
if (rw == NULL)
return 0;
return (rw->rw_owner & RW_THREAD) != 0;
}