From dd41e06795638795345a0a4da9510f948ad81906 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Tue, 7 Feb 2012 23:01:14 +0100 Subject: switch_root: close open file after usage [cppcheck] [sys-utils/switch_root.c:159]: (error) Resource leak: cfd Signed-off-by: Sami Kerola --- sys-utils/switch_root.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sys-utils/switch_root.c') 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; } -- cgit v1.2.3-55-g7522