netlink: unregister groups along with family

Differential Revision:	https://reviews.freebsd.org/D37308
Reviewed by:	melifaro
This commit is contained in:
Baptiste Daroussin 2022-11-08 09:02:43 +01:00
parent b935e867af
commit 1edc3b6e56

View file

@ -133,6 +133,22 @@ free_family(struct genl_family *gf)
free(gf->family_cmds, M_NETLINK);
}
/*
* unregister groups of a given family
*/
static void
unregister_groups(const struct genl_family *gf)
{
for (int i = 0; i < MAX_GROUPS; i++) {
struct genl_group *gg = &groups[i];
if (gg->group_family == gf && gg->group_name != NULL) {
gg->group_family = NULL;
gg->group_name = NULL;
}
}
}
/*
* Can sleep, I guess
*/
@ -148,6 +164,7 @@ genl_unregister_family(const char *family_name)
if (gf != NULL) {
found = true;
unregister_groups(gf);
/* TODO: zero pointer first */
free_family(gf);
bzero(gf, sizeof(*gf));