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: 991826 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="e1Soy6G5"; 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 42lvvl4rx7z9sV8 for ; Thu, 1 Nov 2018 17:10:43 +1100 (AEDT) Received: from localhost ([::1]:35557 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gI6Bl-0005bN-9h for incoming@patchwork.ozlabs.org; Thu, 01 Nov 2018 02:10:41 -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+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 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)