[Skiboot] [PATCH 21/21] chiptod: More hardening against -1 chip ID

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon Nov 14 13:06:21 AEDT 2016


Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
 hw/chiptod.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/chiptod.c b/hw/chiptod.c
index 0a7ea2f..16dd0ae 100644
--- a/hw/chiptod.c
+++ b/hw/chiptod.c
@@ -454,6 +454,9 @@ static enum chiptod_chip_status _chiptod_get_chip_status(int32_t chip_id)
 	uint64_t tod_status;
 	enum chiptod_chip_status status = -1;
 
+	if (chip_id < 0)
+		return chiptod_backup_disabled;
+
 	if (xscom_read(chip_id, TOD_STATUS, &tod_status)) {
 		prerror("XSCOM error reading TOD_STATUS reg\n");
 		return status;
@@ -477,6 +480,9 @@ static void chiptod_update_topology(enum chiptod_topology topo)
 {
 	int32_t chip_id = chiptod_topology_info[topo].id;
 
+	if (chip_id < 0)
+		return;
+
 	chiptod_topology_info[topo].role = chiptod_get_chip_role(topo, chip_id);
 	chiptod_topology_info[topo].status = chiptod_get_chip_status(topo);
 
-- 
2.7.4



More information about the Skiboot mailing list