⬢ DragonFlyBSD Kernel Audit
DF-4549 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/powermng/viapm/viapm.c
+++ b/sys/dev/powermng/viapm/viapm.c
@@ -565,23 +565,25 @@ viapm_busy(struct viapm_softc *viapm)
 static int
 viapm_wait(struct viapm_softc *viapm)
 {
 	int count = 10000;
 	u_char sts = 0;
 	int error;
+	int done = 0;
 
 	/* wait for command to complete and SMBus controller is idle */
 	while(count--) {
 		DELAY(10);
 		sts = VIAPM_INB(SMBHST);
 
 		/* check if the controller is processing a command */
 		if (!(sts & SMBHST_BUSY) && (sts & SMBHST_INTR))
+			done = 1;
 			break;
 	}
 
 	VIAPM_DEBUG(kprintf("viapm: SMBHST=0x%x\n", sts));
 
 	error = SMB_ENOERR;
 
-	if (!count)
+	if (!done)
 		error |= SMB_ETIMEOUT;