All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] fw_cfg_reboot: ensure reboot_time is nonegative
@ 2018-10-24  7:11 Li Qiang
  2018-10-24 11:35 ` Laszlo Ersek
  0 siblings, 1 reply; 9+ messages in thread
From: Li Qiang @ 2018-10-24  7:11 UTC (permalink / raw)
  To: lersek, peter.maydell, pbonzini; +Cc: qemu-devel, Li Qiang

This can avoid setting a negative value to
etc/boot-fail-wait.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 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)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-11-01  6:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24  7:11 [Qemu-devel] [PATCH] fw_cfg_reboot: ensure reboot_time is nonegative Li Qiang
2018-10-24 11:35 ` Laszlo Ersek
2018-10-24 22:56   ` Philippe Mathieu-Daudé
2018-10-25  1:45     ` Li Qiang
2018-10-29 23:50       ` Philippe Mathieu-Daudé
2018-10-30  1:29         ` Li Qiang
2018-10-31 15:46   ` Markus Armbruster
2018-10-31 15:54   ` Eric Blake
2018-11-01  6:13     ` Li Qiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.