⬢ DragonFlyBSD Kernel Audit
DF-5622 / fix.diff
← back to finding ↓ download raw
--- a/sys/platform/pc64/x86_64/cpufreq_machdep.c
+++ b/sys/platform/pc64/x86_64/cpufreq_machdep.c
@@ -84,13 +84,18 @@ amd0f_set_fidvid(const struct amd0f_fidvid *fv, const struct amd0f_xsit *xsit)
 	if (fv->fid == cfid && fv->vid == cvid)
 		return 0;
 
 	/*
 	 * Phase 1: Raise core voltage to requested VID if frequency is
 	 * going up.
 	 */
 	if ((fv->fid & ~0x1) > (cfid & ~0x1) || cvid > fv->vid) {
-		KKASSERT(fv->vid >= xsit->rvo);
+		if (fv->vid < xsit->rvo) {
+			kprintf("amd0f: invalid P-state (vid %u < rvo %u)\n",
+				fv->vid, xsit->rvo);
+			return EINVAL;
+		}
 	} else {
-		KKASSERT(cvid >= xsit->rvo);
+		if (cvid < xsit->rvo)
+			return EINVAL;
 	}
 	while (cvid > fv->vid) {