From efc4506664ea4a713483bfc0b34078982ed7670a Mon Sep 17 00:00:00 2001 From: longlong yan Date: Tue, 18 Aug 2026 10:20:34 +0800 Subject: [PATCH] tools/firewire: nosy-dump: guard close(fd) when reading from input file The file descriptor fd is initialized to -1 and only opened via open() when the --input option is not used. However, close(fd) is called unconditionally at the end of main(), which results in close(-1) and a spurious EBADF error when nosy-dump reads from an input file. Guard the close() call with "if (fd >= 0)" to match the existing conditional cleanup pattern used for the output file handle. Signed-off-by: longlong yan Signed-off-by: Takashi Sakamoto --- tools/firewire/nosy-dump.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/firewire/nosy-dump.c b/tools/firewire/nosy-dump.c index 9a906de3a9ef..9cc8626a7e94 100644 --- a/tools/firewire/nosy-dump.c +++ b/tools/firewire/nosy-dump.c @@ -1014,7 +1014,8 @@ int main(int argc, const char *argv[]) if (output != NULL) fclose(output); - close(fd); + if (fd >= 0) + close(fd); poptFreeContext(con);