aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2016-11-14 13:06:21 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-11-15 15:06:03 +1100
commit3d88d1d7c77b739637caa757ae50b9287f9ef1bb (patch)
treeb65e226b9d62260c6c4fd63dc485bd87099944df /hw
parent6a5842b5a1769fbfca965d617c2c43f95334400e (diff)
downloadskiboot-3d88d1d7c77b739637caa757ae50b9287f9ef1bb.zip
skiboot-3d88d1d7c77b739637caa757ae50b9287f9ef1bb.tar.gz
skiboot-3d88d1d7c77b739637caa757ae50b9287f9ef1bb.tar.bz2
chiptod: More hardening against -1 chip ID
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/chiptod.c6
1 files changed, 6 insertions, 0 deletions
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);