⬢ DragonFlyBSD Kernel Audit
DF-4461 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/powermng/amdtemp/amdtemp.c
+++ b/sys/dev/powermng/amdtemp/amdtemp.c
@@ -963,8 +963,15 @@ amdtemp_gettemp17to19h(device_t dev, amdsensor_t sensor)
 				    (((int)sensor - CCD_BASE) * sizeof(val)),
 				    &val);
 		KASSERT(error == 0, ("amdsmn_read2"));
-		KASSERT((val & AMDTEMP_17H_CCD_TMP_VALID) != 0,
-		    ("sensor %d: not valid", (int)sensor));
+		/*
+		 * The CCD valid bit is live hardware state: a CCD that was
+		 * valid at probe time may report invalid later (e.g. powered
+		 * down by the SMU).  Handle it gracefully, exactly like the
+		 * probe paths do (amdtemp_probe_ccd_sensors17h/19h), instead
+		 * of panicking INVARIANTS kernels.
+		 */
+		if ((val & AMDTEMP_17H_CCD_TMP_VALID) == 0)
+			return (0);
 		return (amdtemp_decode_fam10h_to_17h(sc->sc_offset, val, true));
 	default:
 		__assert_unreachable();