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: 988492 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="aDREsQJc"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42g1fB1zwpz9s1x for ; Wed, 24 Oct 2018 18:12:00 +1100 (AEDT) Received: from localhost ([::1]:46397 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gFDKe-0006hE-UB for incoming@patchwork.ozlabs.org; Wed, 24 Oct 2018 03:11:56 -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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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)