From: Amit Shah Date: Mon, 28 May 2012 06:48:40 +0000 (+0530) Subject: virtio: rng: allow tasks to be killed that are waiting for rng input X-Git-Tag: next-20120724~58^2~12 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=5e37d54a1877b8340ec943800e0a9317dc952f30;p=karo-tx-linux.git virtio: rng: allow tasks to be killed that are waiting for rng input Use wait_for_completion_killable() instead of wait_for_completion() when waiting for the host to send us entropy. Without this, # cat /dev/hwrng ^C just hangs. Signed-off-by: Amit Shah Signed-off-by: Rusty Russell --- diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 723725bbb96b..c8a935034218 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -55,6 +55,7 @@ static void register_buffer(u8 *buf, size_t size) static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait) { + int ret; if (!busy) { busy = true; @@ -65,7 +66,9 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait) if (!wait) return 0; - wait_for_completion(&have_data); + ret = wait_for_completion_killable(&have_data); + if (ret < 0) + return ret; busy = false;