Skip to content

Commit

Permalink
virtio: rng: allow tasks to be killed that are waiting for rng input
Browse files Browse the repository at this point in the history
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 <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Amit Shah authored and Rusty Russell committed Jul 30, 2012
1 parent ddcc286 commit cc8744e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/char/hw_random/virtio-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down

0 comments on commit cc8744e

Please sign in to comment.