mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
virtio: rng: disallow multiple device registrations, fixes crashes
commit e84e7a56a3
upstream.
The code currently only supports one virtio-rng device at a time.
Invoking guests with multiple devices causes the guest to blow up.
Check if we've already registered and initialised the driver. Also
cleanup in case of registration errors or hot-unplug so that a new
device can be used.
Reported-by: Peter Krempa <pkrempa@redhat.com>
Reported-by: <yunzheng@redhat.com>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
40e0c1e9b6
commit
c8fba58532
1 changed files with 11 additions and 2 deletions
|
@ -89,14 +89,22 @@ static int virtrng_probe(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;
|
||||
}
|
||||
|
||||
|
@ -108,6 +116,7 @@ static void __devexit virtrng_remove(struct virtio_device *vdev)
|
|||
vdev->config->reset(vdev);
|
||||
hwrng_unregister(&virtio_hwrng);
|
||||
vdev->config->del_vqs(vdev);
|
||||
vq = NULL;
|
||||
}
|
||||
|
||||
static struct virtio_device_id id_table[] = {
|
||||
|
|
Loading…
Reference in a new issue