summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-03-13 04:28:45 +0100
committerLinus Torvalds <torvalds@linux-foundation.org>2013-03-13 04:28:45 +0100
commita3633f6730239e7d39316aeb119c1bb9e1e83d66 (patch)
tree18e0eb3cf48df4c9ebead5effb65787169776371 /drivers/char
parentMerge tag 'stable/for-linus-3.9-rc2-tag' of git://git.kernel.org/pub/scm/linu... (diff)
parentvirtio: rng: disallow multiple device registrations, fixes crashes (diff)
downloadlinux-a3633f6730239e7d39316aeb119c1bb9e1e83d66.tar.xz
linux-a3633f6730239e7d39316aeb119c1bb9e1e83d66.zip
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.c13
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 10fd71ccf587..6bf4d47324eb 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)