]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
switch_root: close open file after usage [cppcheck]
authorSami Kerola <kerolasa@iki.fi>
Tue, 7 Feb 2012 22:01:14 +0000 (23:01 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 8 Feb 2012 13:23:28 +0000 (14:23 +0100)
[sys-utils/switch_root.c:159]: (error) Resource leak: cfd

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/switch_root.c

index 1c7375dbed51963e44599e8673ce1e11912a2a92..0da7842952bf1daf2916ed580c35dc8329a37f8c 100644 (file)
@@ -155,11 +155,13 @@ static int switchroot(const char *newroot)
        cfd = open("/", O_RDONLY);
 
        if (mount(newroot, "/", NULL, MS_MOVE, NULL) < 0) {
+               close(cfd);
                warn(_("failed to mount moving %s to /"), newroot);
                return -1;
        }
 
        if (chroot(".")) {
+               close(cfd);
                warn(_("failed to change root"));
                return -1;
        }