From 3e9ec69a352e8c7cfbcc5ad6562148fd0223b0f4 Mon Sep 17 00:00:00 2001 From: Andriy Gapon Date: Tue, 18 Dec 2018 17:17:53 +0000 Subject: [PATCH] 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 --- sys/dev/ichwd/ichwd.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/dev/ichwd/ichwd.c b/sys/dev/ichwd/ichwd.c index c29cee9f0a8..12cf5ec592f 100644 --- a/sys/dev/ichwd/ichwd.c +++ b/sys/dev/ichwd/ichwd.c @@ -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);