aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Stanley <joel@jms.id.au>2018-06-05 16:43:34 +0930
committerStewart Smith <stewart@linux.ibm.com>2018-06-18 22:13:43 -0500
commit3754022e50d5e18a6b688299ab350e7d259cae59 (patch)
tree0283f4ba42699be0b8d601a887bf3622f82a8a57
parent900f86ab6ff7a2b56bb99af25344f44d3415b895 (diff)
downloadskiboot-3754022e50d5e18a6b688299ab350e7d259cae59.zip
skiboot-3754022e50d5e18a6b688299ab350e7d259cae59.tar.gz
skiboot-3754022e50d5e18a6b688299ab350e7d259cae59.tar.bz2
occ-sensor: Avoid using uninitialised struct cpu_thread
When adding the sensors in occ_sensors_init, if the type is not OCC_SENSOR_LOC_CORE, then the loop to find 'c' will not be executed. Then c->pir is used for both of the the add_sensor_node calls below. This provides a default value of 0 instead. Found using scan-build. Signed-off-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
-rw-r--r--hw/occ-sensor.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hw/occ-sensor.c b/hw/occ-sensor.c
index a31a2a5..783f757 100644
--- a/hw/occ-sensor.c
+++ b/hw/occ-sensor.c
@@ -543,6 +543,7 @@ bool occ_sensors_init(void)
for (i = 0; i < hb->nr_sensors; i++) {
const char *type, *loc;
struct cpu_thread *c = NULL;
+ uint32_t pir = 0;
if (md[i].structure_type != OCC_SENSOR_READING_FULL)
continue;
@@ -565,6 +566,7 @@ bool occ_sensors_init(void)
break;
if (!c)
continue;
+ pir = c->pir;
}
type = get_sensor_type_string(md[i].type);
@@ -572,7 +574,7 @@ bool occ_sensors_init(void)
add_sensor_node(loc, type, i, SENSOR_SAMPLE, &md[i],
&phandles[phcount], &ptype[phcount],
- c->pir, occ_num, chip->id);
+ pir, occ_num, chip->id);
phcount++;
/* Add energy sensors */
@@ -581,7 +583,7 @@ bool occ_sensors_init(void)
add_sensor_node(loc, "energy", i,
SENSOR_ACCUMULATOR, &md[i],
&phandles[phcount], &ptype[phcount],
- c->pir, occ_num, chip->id);
+ pir, occ_num, chip->id);
phcount++;
}