util: fix close() call on wrong variable
Detected by "cppcheck" (actually it detected a file descriptor leak)
This commit is contained in:
committed by
Lennart Poettering
parent
10d975f54c
commit
678abaf91e
+6
-3
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user