mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 21:57:43 +00:00
i2c: Test off by one in {piix4,vt596}_transaction()
With `while (timeout++ < MAX_TIMEOUT)' timeout reaches MAX_TIMEOUT + 1 after the loop. This is probably unlikely to produce a problem. Signed-off-by: Roel Kluin <roel.kluin@gmail.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
This commit is contained in:
parent
0b2c368844
commit
b6a3195070
2 changed files with 4 additions and 4 deletions
|
@ -324,12 +324,12 @@ static int piix4_transaction(void)
|
||||||
else
|
else
|
||||||
msleep(1);
|
msleep(1);
|
||||||
|
|
||||||
while ((timeout++ < MAX_TIMEOUT) &&
|
while ((++timeout < MAX_TIMEOUT) &&
|
||||||
((temp = inb_p(SMBHSTSTS)) & 0x01))
|
((temp = inb_p(SMBHSTSTS)) & 0x01))
|
||||||
msleep(1);
|
msleep(1);
|
||||||
|
|
||||||
/* If the SMBus is still busy, we give up */
|
/* If the SMBus is still busy, we give up */
|
||||||
if (timeout >= MAX_TIMEOUT) {
|
if (timeout == MAX_TIMEOUT) {
|
||||||
dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
|
dev_err(&piix4_adapter.dev, "SMBus Timeout!\n");
|
||||||
result = -ETIMEDOUT;
|
result = -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,10 +165,10 @@ static int vt596_transaction(u8 size)
|
||||||
do {
|
do {
|
||||||
msleep(1);
|
msleep(1);
|
||||||
temp = inb_p(SMBHSTSTS);
|
temp = inb_p(SMBHSTSTS);
|
||||||
} while ((temp & 0x01) && (timeout++ < MAX_TIMEOUT));
|
} while ((temp & 0x01) && (++timeout < MAX_TIMEOUT));
|
||||||
|
|
||||||
/* If the SMBus is still busy, we give up */
|
/* If the SMBus is still busy, we give up */
|
||||||
if (timeout >= MAX_TIMEOUT) {
|
if (timeout == MAX_TIMEOUT) {
|
||||||
result = -ETIMEDOUT;
|
result = -ETIMEDOUT;
|
||||||
dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
|
dev_err(&vt596_adapter.dev, "SMBus timeout!\n");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue