[Skiboot] [PATCH] sensors: dts: Fix uninitialised data in dts result when reading asynchronously

Nicholas Piggin npiggin at gmail.com
Sun Mar 25 18:53:17 AEDT 2018

dts_async_read_temp() must zero its on-stack dts structure, similarly
to dts_sensor_read().

Cc: Shilpasri G Bhat <shilpa.bhat at linux.vnet.ibm.com>
Cc: C├ędric Le Goater <clg at kaod.org>
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>

The used uninitialized warning showed up when I tried to compile
skiboot with -O2. Too bad -Os and other static checkers didn't
catch it.

I excitedly thought this might also be the cause of the FIXME:,
but it looks like that predates this bug, and came over from the
P8 implementation. Has it been tested that the trip bits are still
wrong? Maybe we can remove it for p9 now?


 hw/dts.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/hw/dts.c b/hw/dts.c
index 949791b0..38811fa9 100644
--- a/hw/dts.c
+++ b/hw/dts.c
@@ -228,11 +228,6 @@ static int dts_read_core_temp_p9(uint32_t pir, struct dts *dts)
 	prlog(PR_TRACE, "DTS: Chip %x Core %x temp:%dC trip:%x\n",
 	      chip_id, core, dts->temp, dts->trip);
-	/*
-	 * FIXME: The trip bits are always set ?! Just discard
-	 * them for the moment until we understand why.
-	 */
-	dts->trip = 0;
 	return 0;
@@ -245,6 +240,7 @@ static void dts_async_read_temp(struct timer *t __unused, void *data,
 	swkup_rc = dctl_set_special_wakeup(cpu);
+	memset(&dts, 0, sizeof(dts));
 	rc = dts_read_core_temp_p9(cpu->pir, &dts);
 	if (!rc) {
 		if (cpu->sensor_attr == SENSOR_DTS_ATTR_TEMP_MAX)

More information about the Skiboot mailing list