diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-12 20:28:45 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-03-12 20:28:45 -0700 |
commit | a3633f6730239e7d39316aeb119c1bb9e1e83d66 (patch) | |
tree | 18e0eb3cf48df4c9ebead5effb65787169776371 /drivers/char | |
parent | 7946844ae890282fa03f52d226d12dda48164f10 (diff) | |
parent | e84e7a56a3aa2963db506299e29a5f3f09377f9b (diff) | |
download | op-kernel-dev-a3633f6730239e7d39316aeb119c1bb9e1e83d66.zip op-kernel-dev-a3633f6730239e7d39316aeb119c1bb9e1e83d66.tar.gz |
Merge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull virtio rng buffix from Rusty Russell:
"Simple virtio-rng fix."
* tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
virtio: rng: disallow multiple device registrations, fixes crashes
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index 10fd71c..6bf4d47 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -92,14 +92,22 @@ static int probe_common(struct virtio_device *vdev) { int err; + if (vq) { + /* We only support one device for now */ + return -EBUSY; + } /* We expect a single virtqueue. */ vq = virtio_find_single_vq(vdev, random_recv_done, "input"); - if (IS_ERR(vq)) - return PTR_ERR(vq); + if (IS_ERR(vq)) { + err = PTR_ERR(vq); + vq = NULL; + return err; + } err = hwrng_register(&virtio_hwrng); if (err) { vdev->config->del_vqs(vdev); + vq = NULL; return err; } @@ -112,6 +120,7 @@ static void remove_common(struct virtio_device *vdev) busy = false; hwrng_unregister(&virtio_hwrng); vdev->config->del_vqs(vdev); + vq = NULL; } static int virtrng_probe(struct virtio_device *vdev) |