Skip to content

Commit f486b8e

Browse files
Simon Lindgrengregkh
authored andcommitted
i2c: at91: Fix a race condition during signal handling in at91_do_twi_xfer.
commit 6721f28 upstream. There is a race condition in at91_do_twi_xfer when signals arrive. If a signal is recieved while waiting for a transfer to complete wait_for_completion_interruptible_timeout() will return -ERESTARTSYS. This is not handled correctly resulting in interrupts still being enabled and a transfer being in flight when we return. Symptoms include a range of oopses and bus lockups. Oopses can happen when the transfer completes because the interrupt handler will corrupt the stack. If a new transfer is started before the interrupt fires the controller will start a new transfer in the middle of the old one, resulting in confused slaves and a locked bus. To avoid this, use wait_for_completion_io_timeout instead so that we don't have to deal with gracefully shutting down the transfer and disabling the interrupts. Signed-off-by: Simon Lindgren <simon@aqwary.com> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 383e210 commit f486b8e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎drivers/i2c/busses/i2c-at91.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ static int at91_do_twi_transfer(struct at91_twi_dev *dev)
434434
}
435435
}
436436

437-
ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
438-
dev->adapter.timeout);
437+
ret = wait_for_completion_io_timeout(&dev->cmd_complete,
438+
dev->adapter.timeout);
439439
if (ret == 0) {
440440
dev_err(dev->dev, "controller timed out\n");
441441
at91_init_twi_bus(dev);

0 commit comments

Comments
 (0)