From patchwork Fri Aug 30 08:35:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amos Kong X-Patchwork-Id: 271171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A9AF82C0087 for ; Fri, 30 Aug 2013 18:36:27 +1000 (EST) Received: from localhost ([::1]:48021 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFKBt-0006ri-Ay for incoming@patchwork.ozlabs.org; Fri, 30 Aug 2013 04:36:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFKBZ-0006rT-3K for qemu-devel@nongnu.org; Fri, 30 Aug 2013 04:36:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VFKBT-0002sO-4d for qemu-devel@nongnu.org; Fri, 30 Aug 2013 04:36:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:16195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VFKBS-0002sH-TQ for qemu-devel@nongnu.org; Fri, 30 Aug 2013 04:35:59 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7U8Zv5o009558 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 30 Aug 2013 04:35:57 -0400 Received: from amosk.info.com ([10.66.6.179]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r7U8Ztmx016256; Fri, 30 Aug 2013 04:35:56 -0400 From: Amos Kong To: qemu-devel@nongnu.org Date: Fri, 30 Aug 2013 16:35:51 +0800 Message-Id: <1377851751-23154-1-git-send-email-akong@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: amit.shah@redhat.com Subject: [Qemu-devel] [PATCH] virtio-rng: add check of period X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Reviewed-by: Amit Shah --- 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));