From: Sami Kerola Date: Tue, 7 Feb 2012 22:01:14 +0000 (+0100) Subject: switch_root: close open file after usage [cppcheck] X-Git-Tag: v2.21~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dd41e06795638795345a0a4da9510f948ad81906;p=thirdparty%2Futil-linux.git switch_root: close open file after usage [cppcheck] [sys-utils/switch_root.c:159]: (error) Resource leak: cfd Signed-off-by: Sami Kerola --- diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index 1c7375dbed..0da7842952 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; }