aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/hw_random/virtio-rng.c
diff options
context:
space:
mode:
authorJames Morris <james.l.morris@oracle.com>2014-10-01 00:44:04 +1000
committerJames Morris <james.l.morris@oracle.com>2014-10-01 00:44:04 +1000
commit6c8ff877cdf13cd5287ed9d700cfb6cb70e2bfa1 (patch)
tree2ab49b7d19fb69cdae5b6be9e7ba44f6cf3d45ef /drivers/char/hw_random/virtio-rng.c
parentMerge tag 'keys-next-20140922' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs into next (diff)
parentLinux 3.16 (diff)
downloadlinux-dev-6c8ff877cdf13cd5287ed9d700cfb6cb70e2bfa1.tar.xz
linux-dev-6c8ff877cdf13cd5287ed9d700cfb6cb70e2bfa1.zip
Merge commit 'v3.16' into next
Diffstat (limited to 'drivers/char/hw_random/virtio-rng.c')
-rw-r--r--drivers/char/hw_random/virtio-rng.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index f3e71501de54..e9b15bc18b4d 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -38,6 +38,8 @@ struct virtrng_info {
int index;
};
+static bool probe_done;
+
static void random_recv_done(struct virtqueue *vq)
{
struct virtrng_info *vi = vq->vdev->priv;
@@ -67,6 +69,13 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait)
int ret;
struct virtrng_info *vi = (struct virtrng_info *)rng->priv;
+ /*
+ * Don't ask host for data till we're setup. This call can
+ * happen during hwrng_register(), after commit d9e7972619.
+ */
+ if (unlikely(!probe_done))
+ return 0;
+
if (!vi->busy) {
vi->busy = true;
init_completion(&vi->have_data);
@@ -137,6 +146,7 @@ static int probe_common(struct virtio_device *vdev)
return err;
}
+ probe_done = true;
return 0;
}