Skip to contentSkip to conversation

virtio-rng: add check of period

PATCH Superseded Amos Kong 2 participants 2 messages Aug 30, 2013

lore
Share & tools
lore

Amos Kong

author
#0 lore raw

PATCH 1/1 virtio-rng: add check of period

If period is assigned to 0, limit timer will expire immediately. This limit is meaningless. This patch forbids to assign 0 to period.

---
 hw/virtio/virtio-rng.c | 6 ++++++
 1 file changed, 6 insertions(+)
hw/virtio/virtio-rng.c +6 -0
index 314e393..b22ccf1 100644
@@ -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));
 
Signature · 1 line
1.8.3.1