virtio-rng: add check of period
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.
Signed-off-by Amos Kong <[email protected]>
--- hw/virtio/virtio-rng.c | 6 ++++++ 1 file changed, 6 insertions(+)
hw/virtio/virtio-rng.c +6 -0
@@ -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
Quoted 5 lines · Amos Kong
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 <[email protected]>
Reviewed-by Amit Shah <[email protected]>
Amit