]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
tools: kwboot: Fix restoring terminal
authorPali Rohár <pali@kernel.org>
Fri, 23 Jul 2021 09:14:18 +0000 (11:14 +0200)
committerStefan Roese <sr@denx.de>
Sat, 31 Jul 2021 07:49:31 +0000 (09:49 +0200)
Call tcsetattr() only if the file descriptor is valid. It may be
invalidated by previous lines (if it is not a tty descriptor).

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Chris Packham <judge.packham@gmail.com>
Tested-by: Chris Packham <judge.packham@gmail.com>
tools/kwboot.c

index 1ba5ded5d3899e80d4517658e2626839b85080e3..7fa742d84cc32d99173db09675bc5f1e5755a327 100644 (file)
@@ -558,7 +558,8 @@ kwboot_terminal(int tty)
                }
        } while (quit[s] != 0);
 
-       tcsetattr(in, TCSANOW, &otio);
+       if (in >= 0)
+               tcsetattr(in, TCSANOW, &otio);
 out:
        return rc;
 }