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
This commit is contained in:
Lawrence Stewart 2013-06-14 02:25:40 +00:00
parent 563d463961
commit 86241d89a9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251725

View File

@ -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);
}