Kirkwood: Fix tv sec/usec normalization in kwboot

Dagan Martinez dmartinez at starry.com
Thu Apr 29 14:03:02 CEST 2021


>From c200095d4136a071dd9526a48be642ce58fae8c9 Mon Sep 17 00:00:00 2001
From: Dagan Martinez <dmartinez at starry.com>
Date: Tue, 27 Apr 2021 15:48:31 -0400
Subject: [PATCH v2] Kirkwood: Fix tv sec/usec normalization in kwboot

`kwboot.c` had an issue where it failed to normalize the `tv` struct in
the case where the `tv_usec` field was 1000000, ie one second.

This caused issues on Fedora Linux 34, where `select` would return
`EINVAL`, preventing kwboot from communicating with the board.

Signed-off-by: Dagan Martinez <dmartinez at starry.com>
---
Changes for v2:
   - Use real author name in patch


 tools/kwboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/kwboot.c b/tools/kwboot.c
index 4be094c9c8..5d5d501d36 100644
--- a/tools/kwboot.c
+++ b/tools/kwboot.c
@@ -167,7 +167,7 @@ kwboot_tty_recv(int fd, void *buf, size_t len, int timeo)

     tv.tv_sec = 0;
     tv.tv_usec = timeo * 1000;
-    if (tv.tv_usec > 1000000) {
+    if (tv.tv_usec >= 1000000) {
         tv.tv_sec += tv.tv_usec / 1000000;
         tv.tv_usec %= 1000000;
     }
-- 
2.31.1


More information about the U-Boot mailing list