From: Thomas Jarosch Date: Wed, 5 Oct 2011 20:31:41 +0000 (+0200) Subject: util: fix close() call on wrong variable X-Git-Tag: v37~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=678abaf91e2308f02fb679c2dc2679a3b6a5b8be;p=platform%2Fupstream%2Fsystemd.git util: fix close() call on wrong variable Detected by "cppcheck" (actually it detected a file descriptor leak) --- diff --git a/src/util.c b/src/util.c index 7977ee4..e46606d 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; }