From patchwork Wed Oct 24 07:11:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10654191 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 7658213B5 for ; Wed, 24 Oct 2018 07:12:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 654B52A688 for ; Wed, 24 Oct 2018 07:12:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56FD32A695; Wed, 24 Oct 2018 07:12:17 +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 DB9F22A688 for ; Wed, 24 Oct 2018 07:12:16 +0000 (UTC) Received: from localhost ([::1]:46398 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFDKx-0006zY-Me for patchwork-qemu-devel@patchwork.kernel.org; Wed, 24 Oct 2018 03:12:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFDKG-0006gx-Fh for qemu-devel@nongnu.org; Wed, 24 Oct 2018 03:11:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gFDKD-0004cN-B0 for qemu-devel@nongnu.org; Wed, 24 Oct 2018 03:11:32 -0400 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:37628) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gFDKB-0004a6-6i for qemu-devel@nongnu.org; Wed, 24 Oct 2018 03:11:27 -0400 Received: by mail-pl1-x643.google.com with SMTP id bh10-v6so1836504plb.4 for ; Wed, 24 Oct 2018 00:11:26 -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=ITtCGxcLS3AdXXHIk730+Rhe13QU28CZxHVy81aQd1M=; b=aDREsQJcooXwXixVW4h1BWTPh4sZCUAPULaazN7W4j+FM8zJXgfZg0WkJw5OsjNvMU 8WAH3FCV/S6uW+Az/vHkkarVW8DDyY4Yb4cqNWJSpyaX6oFwjp8hd7m8kuwSt/9KzuMW LSqAXK//cBL3Ngvs/UkC7cebtua4jrYQ7pLt3p0q0JBf0KQ5nEjgWRS0juwwKIlvhN5d MNvvfu+q0goUpRFASflTwDEkUHO0xeJwfJ9meVsZyjyWSzrqgsVTrZksFiduf0458X07 qG4ZGjEdJyOxJmlQVcX05cuiK81NDOpp8Fs5NCK81l7+GSDYAD9upva+lwVZvT2K8l/i JXWQ== 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=ITtCGxcLS3AdXXHIk730+Rhe13QU28CZxHVy81aQd1M=; b=R2j6IeGlmfmWhCpkGhT2n5iZ1xoRVnIDElGlDb3DYzo22LXJo5dJ+5UF+5TqMjIYew xzseukU3Jjlsx+LhYNH0EXAlFONiv4fdEHeiLXkeH42cujmA87Trr9MZOaiSoei975lU k9JThfeyEeanfOwPhxZUVIqFcKx8yzlUSXGKtppMYQ4Hv5Cl5v1rrTj08QkBrLdPGzS2 MiuKTFQ30kcOdnDjeaah48Q+3hd/Har3KI/SNX+IASRoZGaHyqHN7hEpUMkw3hs0Fhl4 R0cT+ibwmVIMLABYOK3xNlKyymyo1ZviHaWY8KlkWUtwDsKVaclDzzdkWx20m57r7ukB dlfw== X-Gm-Message-State: AGRZ1gLb3EEEDhWi5sbdz42sOJD6mFsjcP1lHtfBqEeAg0B8eHSG2q5J DsKL9WDqxp0ZMDzLnsnRh64= X-Google-Smtp-Source: AJdET5eAqMy/daMey0QxfxnIt1JmBYA0DmcU0u1+8nIJMNKkvC8+Vb495KaCCDssHgyN0FymCEZndA== X-Received: by 2002:a17:902:b492:: with SMTP id y18-v6mr1455177plr.254.1540365085627; Wed, 24 Oct 2018 00:11:25 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.100]) by smtp.gmail.com with ESMTPSA id a11-v6sm3871762pgw.54.2018.10.24.00.11.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Oct 2018 00:11:25 -0700 (PDT) From: Li Qiang To: lersek@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com Date: Wed, 24 Oct 2018 00:11:20 -0700 Message-Id: <1540365080-6844-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::643 Subject: [Qemu-devel] [PATCH] fw_cfg_reboot: 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 f4a52d8..276dcb1 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)