Skip to content

Commit a7982a1

Browse files
185264646Andi Shyti
authored andcommitted
i2c: qup: jump out of the loop in case of timeout
Original logic only sets the return value but doesn't jump out of the loop if the bus is kept active by a client. This is not expected. A malicious or buggy i2c client can hang the kernel in this case and should be avoided. This is observed during a long time test with a PCA953x GPIO extender. Fix it by changing the logic to not only sets the return value, but also jumps out of the loop and return to the caller with -ETIMEDOUT. Fixes: fbfab1a ("i2c: qup: reorganization of driver code to remove polling for qup v1") Signed-off-by: Yang Xiwen <[email protected]> Cc: <[email protected]> # v4.17+ Signed-off-by: Andi Shyti <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a663b3c commit a7982a1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/i2c/busses/i2c-qup.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,10 @@ static int qup_i2c_bus_active(struct qup_i2c_dev *qup, int len)
452452
if (!(status & I2C_STATUS_BUS_ACTIVE))
453453
break;
454454

455-
if (time_after(jiffies, timeout))
455+
if (time_after(jiffies, timeout)) {
456456
ret = -ETIMEDOUT;
457+
break;
458+
}
457459

458460
usleep_range(len, len * 2);
459461
}

0 commit comments

Comments
 (0)