[igt-dev] [PATCH i-g-t 1/1] runner: Plug an fd leak

Petri Latvala petri.latvala at intel.com
Thu Sep 27 09:30:56 UTC 2018


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 <petri.latvala at intel.com>
Cc: Arkadiusz Hiler <arkadiusz.hiler at intel.com>
---
 runner/executor.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

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;
 		}
 
-- 
2.18.0



More information about the igt-dev mailing list