diff --git a/tools/firewire/nosy-dump.c b/tools/firewire/nosy-dump.c index 9cc8626a7e94..7ddb50521c29 100644 --- a/tools/firewire/nosy-dump.c +++ b/tools/firewire/nosy-dump.c @@ -947,6 +947,8 @@ int main(int argc, const char *argv[]) output = fopen(option_output, "w"); if (output == NULL) { fprintf(stderr, "Could not open %s, %m\n", option_output); + if (input != NULL) + fclose(input); return -1; } } @@ -973,7 +975,7 @@ int main(int argc, const char *argv[]) while (run) { if (input != NULL) { if (fread(&length, sizeof length, 1, input) != 1) - return 0; + break; fread(buf, 1, length, input); } else { poll(pollfds, 2, -1); @@ -1014,6 +1016,9 @@ int main(int argc, const char *argv[]) if (output != NULL) fclose(output); + if (input != NULL) + fclose(input); + if (fd >= 0) close(fd);