From patchwork Thu Nov 1 06:09:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10663511 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A8E7613A4 for ; Thu, 1 Nov 2018 06:11:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87B312BC49 for ; Thu, 1 Nov 2018 06:11:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 789462BC50; Thu, 1 Nov 2018 06:11:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2E1492BC49 for ; Thu, 1 Nov 2018 06:11:21 +0000 (UTC) Received: from localhost ([::1]:35563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gI6CO-0006Rd-Bq for patchwork-qemu-devel@patchwork.kernel.org; Thu, 01 Nov 2018 02:11:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gI6BB-0005Xn-Ti for qemu-devel@nongnu.org; Thu, 01 Nov 2018 02:10:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gI6B7-0003Z6-0b for qemu-devel@nongnu.org; Thu, 01 Nov 2018 02:10:05 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:36220) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gI6B6-0003Yq-Qe for qemu-devel@nongnu.org; Thu, 01 Nov 2018 02:10:00 -0400 Received: by mail-pg1-x544.google.com with SMTP id z17-v6so8524088pgv.3 for ; Wed, 31 Oct 2018 23:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=q+QyIgLhfL3GM1vaaF2J9pylFwD+5jobPpa2GQXtxHw=; b=e1Soy6G5sjE3OvDip+GT+gI0QOYgnycJsiGCrKw4ClKeWZpMOzYXLaEeFJ7OjFUS8s fgXM+iOVGIqaAvBttZMhmdZZX23vujN9cnwin/c2FSdkl897QaZy1T4wo63TPnCVahbi iaxHs3sIXhQZbpYK+k2i7IAZ45sKuvwnWWH7tpbdnnsFE+hhih5qfhz8lSRMOabwx1ei 5nRbHhQJ1JdPFIxsJIoOdFVoZ8W2NRdmFWDdsLWlEP/WWRZRC1ICBBAq3mMq6X1Clcs4 qI5ASbmQzAJTM1IIJvew140PUOZABe5F7Qefe6O3lFf8SYpgJPighRJ8oL3LrKlDG9IX buWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=q+QyIgLhfL3GM1vaaF2J9pylFwD+5jobPpa2GQXtxHw=; b=kt8KUxP5LfnTsBxxCNRhl35aeMl1Um6e0MhUpkE0tv2CEgc9m7k4lEn85alAw+5AQZ RZ34+6nv5e764tctwASxEEVUe5yRwIXnxXDU4IRHqVmcaQhRpx7XDoreq5stq9CGGd9f /UWV9n7yIvlktDynkvsdhYzt7xnrhVF1dg+tNX1nyjJb3lKnRoAuqNFpNefPGuIyt5D+ QNLtSvBVzb+fmb1YGHj2wb4cRrU9wZHAn8JzAsJDGjJh6K4Zz+BMXBq1UueXaJ2TEXdk gJ7kRdrWYa0ZeyKh0A4OCLUHBb8xY/+GlaZPNAiWJI00D2UKB3SupeIFEVEy0ZCKqniG s17w== X-Gm-Message-State: AGRZ1gKuebtQDOT68o1/XSZQKoKu5yKxsGz8AhiLhvoqAicXynArfuNP skyuCm0ZrLcHJn/hRMdXseo= X-Google-Smtp-Source: AJdET5deHB3PgdzvUaGi9GW55VsgUXJk5+hYl5IN8oETvRkQjnNGp4ZV7yvSSk+DndwlEv2501/kOQ== X-Received: by 2002:a63:608f:: with SMTP id u137mr6021796pgb.203.1541052599877; Wed, 31 Oct 2018 23:09:59 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.100]) by smtp.gmail.com with ESMTPSA id q25-v6sm48299689pfk.154.2018.10.31.23.09.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 23:09:59 -0700 (PDT) From: Li Qiang To: pbonzini@redhat.com, armbru@redhat.com, philmd@redhat.com, lersek@redhat.com, kraxel@redhat.com Date: Wed, 31 Oct 2018 23:09:54 -0700 Message-Id: <1541052594-29132-1-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH 1/2] hw: fw_cfg: ensure reboot_time is nonegative X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This can avoid setting a negative value to etc/boot-fail-wait. Signed-off-by: Li Qiang --- hw/nvram/fw_cfg.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c index 3fcfa35..dff6e06 100644 --- a/hw/nvram/fw_cfg.c +++ b/hw/nvram/fw_cfg.c @@ -199,12 +199,17 @@ static void fw_cfg_reboot(FWCfgState *s) reboot_timeout = strtol(p, &p, 10); } } - /* validate the input */ - if (reboot_timeout > 0xffff) { - error_report("reboot timeout is larger than 65535, force it to 65535."); - reboot_timeout = 0xffff; + + if (reboot_timeout >= 0) { + /* validate the input */ + if (reboot_timeout > 0xffff) { + error_report("reboot timeout is larger than 65535," + "force it to 65535."); + reboot_timeout = 0xffff; + } + fw_cfg_add_file(s, "etc/boot-fail-wait", + g_memdup(&reboot_timeout, 4), 4); } - fw_cfg_add_file(s, "etc/boot-fail-wait", g_memdup(&reboot_timeout, 4), 4); } static void fw_cfg_write(FWCfgState *s, uint8_t value)