diff options
| author | Viresh Kumar <viresh.kumar@linaro.org> | 2025-07-03 17:01:02 +0530 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-08-01 09:47:30 +0100 |
| commit | 6e7836c83635a6c460baaf9ed1eb20b3ec74fe8f (patch) | |
| tree | 17cf7272c5610954ce71903df935eb4e50c21dd5 | |
| parent | 68ceeb06316e46130d0d833e241d994381cc7455 (diff) | |
| download | linux-6e7836c83635a6c460baaf9ed1eb20b3ec74fe8f.tar.gz linux-6e7836c83635a6c460baaf9ed1eb20b3ec74fe8f.tar.bz2 linux-6e7836c83635a6c460baaf9ed1eb20b3ec74fe8f.zip | |
i2c: virtio: Avoid hang by using interruptible completion wait
commit a663b3c47ab10f66130818cf94eb59c971541c3f upstream.
The current implementation uses wait_for_completion(), which can cause
the caller to hang indefinitely if the transfer never completes.
Switch to wait_for_completion_interruptible() so that the operation can
be interrupted by signals.
Fixes: 84e1d0bf1d71 ("i2c: virtio: disable timeout handling")
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: <stable@vger.kernel.org> # v5.16+
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/b8944e9cab8eb959d888ae80add6f2a686159ba2.1751541962.git.viresh.kumar@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| -rw-r--r-- | drivers/i2c/busses/i2c-virtio.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/i2c/busses/i2c-virtio.c b/drivers/i2c/busses/i2c-virtio.c index c60ae531ba57..726c162cabd8 100644 --- a/drivers/i2c/busses/i2c-virtio.c +++ b/drivers/i2c/busses/i2c-virtio.c @@ -116,15 +116,16 @@ static int virtio_i2c_complete_reqs(struct virtqueue *vq, for (i = 0; i < num; i++) { struct virtio_i2c_req *req = &reqs[i]; - wait_for_completion(&req->completion); - - if (!failed && req->in_hdr.status != VIRTIO_I2C_MSG_OK) - failed = true; + if (!failed) { + if (wait_for_completion_interruptible(&req->completion)) + failed = true; + else if (req->in_hdr.status != VIRTIO_I2C_MSG_OK) + failed = true; + else + j++; + } i2c_put_dma_safe_msg_buf(reqs[i].buf, &msgs[i], !failed); - - if (!failed) - j++; } return j; |
