Message ID | 20180913150613.16265-1-tvrtko.ursulin@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [PATH,i-g-t] igt_sysfs: Avoid double closing the fd in igt_sysfs_scanf | expand |
Quoting Tvrtko Ursulin (2018-09-13 16:06:13) > From: Tvrtko Ursulin <tvrtko.ursulin@intel.com> > > fdopen takes ownership of the fd so only one flavour of closing it is > needed. Indeed, I always seem to get burned by this. One day I might remember... Who am I kidding? :) > Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> -Chris
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; }