projects
/
dragonfly.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
(parent:
18b4c2b
)
kernel - Add sysref assertions
author
Matthew Dillon <dillon@apollo.backplane.com>
Fri, 13 Aug 2010 04:48:45 +0000 (21:48 -0700)
committer
Matthew Dillon <dillon@apollo.backplane.com>
Fri, 13 Aug 2010 04:48:45 +0000 (21:48 -0700)
* Add more checks in the sysref code to detect use-after-free situations.
sys/sys/sysref2.h
patch
|
blob
|
blame
|
history
diff --git
a/sys/sys/sysref2.h
b/sys/sys/sysref2.h
index
ce9bf08
..
1e765cf
100644
(file)
--- a/
sys/sys/sysref2.h
+++ b/
sys/sys/sysref2.h
@@
-67,6
+67,7
@@
static __inline
void
sysref_get(struct sysref *sr)
{
+ KKASSERT((sr->flags & SRF_PUTAWAY) == 0);
atomic_add_int(&sr->refcnt, 1);
}
@@
-81,6
+82,7
@@
sysref_put(struct sysref *sr)
{
int count = sr->refcnt;
+ KKASSERT((sr->flags & SRF_PUTAWAY) == 0);
if (count <= 1 || atomic_cmpset_int(&sr->refcnt, count, count - 1) == 0)
_sysref_put(sr);
}