From 86241d89a9110c65c380665ffcf0dda236f29fdc Mon Sep 17 00:00:00 2001 From: Lawrence Stewart Date: Fri, 14 Jun 2013 02:25:40 +0000 Subject: [PATCH] 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 --- sys/kern/kern_hhook.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_hhook.c b/sys/kern/kern_hhook.c index 1e34044e7e0f..4f5d144933d7 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); }