switch_root: check open() return value [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2012-09-07 13:02:42 +02:00
parent fee9431f97
commit 17df84df27
1 changed files with 4 additions and 0 deletions

View File

@ -154,6 +154,10 @@ static int switchroot(const char *newroot)
}
cfd = open("/", O_RDONLY);
if (cfd < 0) {
warn(_("cannot open %s"), "/");
return -1;
}
if (mount(newroot, "/", NULL, MS_MOVE, NULL) < 0) {
close(cfd);