diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2021-11-25 13:00:17 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2022-01-14 18:50:52 -0500 |
commit | 2076207128948b766ef1fe344e0444fc9271a847 (patch) | |
tree | b8df7ec9d66851f4f5eb843a7d4b8b7c1a277b86 /drivers | |
parent | d9679d0013a66849f23057978f92e76b255c50aa (diff) | |
download | linux-2076207128948b766ef1fe344e0444fc9271a847.tar.bz2 |
hwrng: virtio - unregister device before reset
unregister after reset is clearly wrong - device
can be used while it's reset. There's an attempt to
protect against that using hwrng_removed but it
seems racy since access can be in progress
when the flag is set.
Just unregister, then reset seems simpler and cleaner.
NB: we might be able to drop hwrng_removed in a follow-up patch.
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/hw_random/virtio-rng.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index b2bf78b25630..e856df7e285c 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c @@ -179,9 +179,9 @@ static void remove_common(struct virtio_device *vdev) vi->data_avail = 0; vi->data_idx = 0; complete(&vi->have_data); - virtio_reset_device(vdev); if (vi->hwrng_register_done) hwrng_unregister(&vi->hwrng); + virtio_reset_device(vdev); vdev->config->del_vqs(vdev); ida_simple_remove(&rng_index_ida, vi->index); kfree(vi); |