netlink: Avoid potential undefined behaviour

Taking the address of an OOB array element is UB, even if not
dereferenced.

Reviewed by: des, bz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D57172
This commit is contained in:
Ed Maste
2026-05-22 10:55:49 -04:00
parent c74645b0c8
commit 4d125ed6e7
+3 -5
View File
@@ -93,12 +93,10 @@ static struct genl_group {
static inline struct genl_family *
genl_family(uint16_t family_id)
{
struct genl_family *gf;
gf = &families[family_id - GENL_MIN_ID];
KASSERT(family_id - GENL_MIN_ID < MAX_FAMILIES &&
gf->family_name != NULL, ("family %u does not exist", family_id));
return (gf);
families[family_id - GENL_MIN_ID].family_name != NULL,
("family %u does not exist", family_id));
return (&families[family_id - GENL_MIN_ID]);
}
static inline uint16_t