summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Jarosch <thomas.jarosch@intra2net.com>2011-10-05 22:31:41 +0200
committerLennart Poettering <lennart@poettering.net>2011-10-10 22:30:57 +0200
commit678abaf91e2308f02fb679c2dc2679a3b6a5b8be (patch)
tree927ea42d2586b830b2b4efc2e9242a82028c3030
parent10d975f54c88223fb8762a226fd011ec3f30f2eb (diff)
util: fix close() call on wrong variable
Detected by "cppcheck" (actually it detected a file descriptor leak)
-rw-r--r--src/util.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index 7977ee46c5..e46606dabb 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2307,8 +2307,10 @@ int chvt(int vt) {
0
};
- if (ioctl(fd, TIOCLINUX, tiocl) < 0)
- return -errno;
+ if (ioctl(fd, TIOCLINUX, tiocl) < 0) {
+ r = -errno;
+ goto fail;
+ }
vt = tiocl[0] <= 0 ? 1 : tiocl[0];
}
@@ -2316,7 +2318,8 @@ int chvt(int vt) {
if (ioctl(fd, VT_ACTIVATE, vt) < 0)
r = -errno;
- close_nointr_nofail(r);
+fail:
+ close_nointr_nofail(fd);
return r;
}