From bdc8989328f57ec2e63a88c89a45440567c69eeb Mon Sep 17 00:00:00 2001 From: Petri Latvala Date: Thu, 27 Sep 2018 12:30:56 +0300 Subject: runner: Plug an fd leak Make sure comparefd gets closed in dump_dmesg(). Otherwise we run out of descriptors after a bit over 1000 tests executed... Signed-off-by: Petri Latvala Cc: Arkadiusz Hiler Reviewed-by: Arkadiusz Hiler --- runner/executor.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'runner') diff --git a/runner/executor.c b/runner/executor.c index fd262eb4..d0539aa1 100644 --- a/runner/executor.c +++ b/runner/executor.c @@ -249,15 +249,19 @@ static void dump_dmesg(int kmsgfd, int outfd) return; lseek(comparefd, 0, SEEK_END); - if (fcntl(kmsgfd, F_SETFL, O_NONBLOCK)) + if (fcntl(kmsgfd, F_SETFL, O_NONBLOCK)) { + close(comparefd); return; + } while (1) { if (comparefd >= 0) { r = read(comparefd, buf, sizeof(buf) - 1); if (r < 0) { - if (errno != EAGAIN && errno != EPIPE) + if (errno != EAGAIN && errno != EPIPE) { + close(comparefd); return; + } } else { buf[r] = '\0'; if (sscanf(buf, "%u,%llu,%llu,%c;", @@ -278,6 +282,7 @@ static void dump_dmesg(int kmsgfd, int outfd) * If EAGAIN, we're done. If some other error, * we can't do anything anyway. */ + close(comparefd); return; } -- cgit v1.2.3