ichwd: add a few assertions about tco_version

Those should ensure correctness of ichwd_find_ich_lpc_bridge() and
ichwd_find_ich_lpc_bridge() as well as make it easier for both humans
and static analyzers to see the relation between tco_version and ich and
smb variables in ichwd_identify().

Reported by:	Coverity
CID:		1396314, 1396317
MFC after:	10 days
This commit is contained in:
avg 2018-12-18 17:17:53 +00:00
parent f3462a1719
commit 3535b6c2ca

View File

@ -635,6 +635,13 @@ ichwd_identify(driver_t *driver, device_t parent)
return;
}
KASSERT(id_p->tco_version >= 1,
("unexpected TCO version %d", id_p->tco_version));
KASSERT(id_p->tco_version != 4 || smb != NULL,
("could not find PCI SMBus device for TCOv4"));
KASSERT(id_p->tco_version >= 4 || ich != NULL,
("could not find PCI LPC bridge device for TCOv1-3"));
/* good, add child to bus */
if ((dev = device_find_child(parent, driver->name, 0)) == NULL)
dev = BUS_ADD_CHILD(parent, 0, driver->name, 0);