summaryrefslogtreecommitdiffstats
path: root/sys-utils/switch_root.c
diff options
context:
space:
mode:
authorSami Kerola2012-02-07 23:01:14 +0100
committerKarel Zak2012-02-08 14:23:28 +0100
commitdd41e06795638795345a0a4da9510f948ad81906 (patch)
treeb7aa69406a5a8c971dc0e1d67a93056ad34826f3 /sys-utils/switch_root.c
parentchcpu: use appropriate variable type [cppcheck] (diff)
downloadkernel-qcow2-util-linux-dd41e06795638795345a0a4da9510f948ad81906.tar.gz
kernel-qcow2-util-linux-dd41e06795638795345a0a4da9510f948ad81906.tar.xz
kernel-qcow2-util-linux-dd41e06795638795345a0a4da9510f948ad81906.zip
switch_root: close open file after usage [cppcheck]
[sys-utils/switch_root.c:159]: (error) Resource leak: cfd Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r--sys-utils/switch_root.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index 1c7375dbe..0da784295 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -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;
}