[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] virtio-rng: add check of period
From: |
Amos Kong |
Subject: |
[Qemu-devel] [PATCH] virtio-rng: add check of period |
Date: |
Fri, 30 Aug 2013 16:35:51 +0800 |
If period is assigned to 0, limit timer will expire immediately.
This limit is meaningless. This patch forbids to assign 0 to
period.
Signed-off-by: Amos Kong <address@hidden>
---
hw/virtio/virtio-rng.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/virtio/virtio-rng.c b/hw/virtio/virtio-rng.c
index 314e393..b22ccf1 100644
--- a/hw/virtio/virtio-rng.c
+++ b/hw/virtio/virtio-rng.c
@@ -139,6 +139,12 @@ static int virtio_rng_device_init(VirtIODevice *vdev)
VirtIORNG *vrng = VIRTIO_RNG(vdev);
Error *local_err = NULL;
+ if (!vrng->conf.period_ms > 0) {
+ qerror_report(QERR_INVALID_PARAMETER_VALUE, "period",
+ "a positive number");
+ return -1;
+ }
+
if (vrng->conf.rng == NULL) {
vrng->conf.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
--
1.8.3.1
- [Qemu-devel] [PATCH] virtio-rng: add check of period,
Amos Kong <=