[igt-dev] [PATH i-g-t] igt_sysfs: Avoid double closing the fd in igt_sysfs_scanf

Tvrtko Ursulin tursulin at ursulin.net
Thu Sep 13 15:06:13 UTC 2018


From: Tvrtko Ursulin <tvrtko.ursulin at intel.com>

fdopen takes ownership of the fd so only one flavour of closing it is
needed.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
 lib/igt_sysfs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/igt_sysfs.c b/lib/igt_sysfs.c
index 9012cc73f6e3..d323b81dd986 100644
--- a/lib/igt_sysfs.c
+++ b/lib/igt_sysfs.c
@@ -379,8 +379,9 @@ int igt_sysfs_scanf(int dir, const char *attr, const char *fmt, ...)
 		va_end(ap);
 
 		fclose(file);
+	} else {
+		close(fd);
 	}
-	close(fd);
 
 	return ret;
 }
-- 
2.17.1



More information about the igt-dev mailing list