summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_hhook.c
diff options
context:
space:
mode:
authorlstewart <lstewart@FreeBSD.org>2013-06-14 02:25:40 +0000
committerlstewart <lstewart@FreeBSD.org>2013-06-14 02:25:40 +0000
commit1144352c6483cb692d8a4ce1189e7bd56224df1c (patch)
tree67531de474fd7a9fb6eaaea5f2c916a85daeab85 /sys/kern/kern_hhook.c
parent248fad72209b1013803c0126070b82b591a6ebba (diff)
downloadFreeBSD-src-1144352c6483cb692d8a4ce1189e7bd56224df1c.zip
FreeBSD-src-1144352c6483cb692d8a4ce1189e7bd56224df1c.tar.gz
Fix a potential NULL-pointer dereference that would trigger if the hhook
registration site did not provide storage for a copy of the hhook_head struct. MFC after: 3 days
Diffstat (limited to 'sys/kern/kern_hhook.c')
-rw-r--r--sys/kern/kern_hhook.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/sys/kern/kern_hhook.c b/sys/kern/kern_hhook.c
index 1e34044..4f5d144 100644
--- a/sys/kern/kern_hhook.c
+++ b/sys/kern/kern_hhook.c
@@ -264,9 +264,10 @@ hhook_head_register(int32_t hhook_type, int32_t hhook_id, struct hhook_head **hh
STAILQ_INIT(&tmphhh->hhh_hooks);
HHH_LOCK_INIT(tmphhh);
- if (hhh != NULL)
+ if (hhh != NULL) {
refcount_init(&tmphhh->hhh_refcount, 1);
- else
+ *hhh = tmphhh;
+ } else
refcount_init(&tmphhh->hhh_refcount, 0);
if (flags & HHOOK_HEADISINVNET) {
@@ -278,8 +279,6 @@ hhook_head_register(int32_t hhook_type, int32_t hhook_id, struct hhook_head **hh
/* XXXLAS: Add tmphhh to the non-virtualised list. */
}
- *hhh = tmphhh;
-
return (0);
}
OpenPOWER on IntegriCloud