diff options
Diffstat (limited to 'drivers/char/hw_random/virtio-rng.c')
-rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 3fa2f8a009b3..b89df66ea1ae 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -184,7 +184,26 @@ static int virtrng_freeze(struct virtio_device *vdev) static int virtrng_restore(struct virtio_device *vdev) { - return probe_common(vdev); + int err; + + err = probe_common(vdev); + if (!err) { + struct virtrng_info *vi = vdev->priv; + + /* + * Set hwrng_removed to ensure that virtio_read() + * does not block waiting for data before the + * registration is complete. + */ + vi->hwrng_removed = true; + err = hwrng_register(&vi->hwrng); + if (!err) { + vi->hwrng_register_done = true; + vi->hwrng_removed = false; + } + } + + return err; } #endif |