From: Amos Kong <akong@redhat.com>
To: stable@vger.kernel.org
Cc: amit.shah@redhat.com, gregkh@linuxfoundation.org,
linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org
Subject: [3.16 stable PATCH 2/2] virtio-rng: skip reading when we start to remove the device
Date: Sat, 11 Oct 2014 06:51:49 +0800 [thread overview]
Message-ID: <1412981509-30025-3-git-send-email-akong@redhat.com> (raw)
In-Reply-To: <1412981509-30025-1-git-send-email-akong@redhat.com>
Before we really unregister the hwrng device, reading will get stuck if
the virtio device is reset. We should return error for reading when we
start to remove the device.
Signed-off-by: Amos Kong <akong@redhat.com>
Reviewed-by: Amit Shah <amit.shah@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
(cherry picked from commit f49819560f53b7f3a596a8ea2e6764dc86695b62)
Signed-off-by: Amos Kong <akong@redhat.com>
---
drivers/char/hw_random/virtio-rng.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c
index b50252c..cb1688a 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -37,6 +37,7 @@ struct virtrng_info {
char name[25];
int index;
bool hwrng_register_done;
+ bool hwrng_removed;
};
@@ -69,6 +70,9 @@ 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;
+ if (vi->hwrng_removed)
+ return -ENODEV;
+
if (!vi->busy) {
vi->busy = true;
init_completion(&vi->have_data);
@@ -137,6 +141,7 @@ static void remove_common(struct virtio_device *vdev)
{
struct virtrng_info *vi = vdev->priv;
+ vi->hwrng_removed = true;
vi->data_avail = 0;
complete(&vi->have_data);
vdev->config->reset(vdev);
--
1.9.3
next prev parent reply other threads:[~2014-10-10 22:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-10 22:51 [3.16 stable PATCH 0/2] virtio-rng: two backports to fix stuck Amos Kong
2014-10-10 22:51 ` [3.16 stable PATCH 1/2] virtio-rng: fix stuck of hot-unplugging busy device Amos Kong
2014-10-10 22:51 ` Amos Kong [this message]
2014-11-04 4:32 ` [3.16 stable PATCH 0/2] virtio-rng: two backports to fix stuck Amos Kong
2014-11-05 16:02 ` Luis Henriques
[not found] ` <20141105160249.GG9403@hercules>
2014-11-05 16:14 ` Amos Kong
2014-11-19 1:20 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1412981509-30025-3-git-send-email-akong@redhat.com \
--to=akong@redhat.com \
--cc=amit.shah@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).