summaryrefslogtreecommitdiffstats
path: root/sys-utils/switch_root.c
diff options
context:
space:
mode:
authorKarel Zak2012-09-07 13:02:42 +0200
committerKarel Zak2012-09-07 13:02:42 +0200
commit17df84df275aa6ebf92dfb727a477bb8c2abe6eb (patch)
tree723a28d4160f4550eb29fdb62a7619c8365ffdfa /sys-utils/switch_root.c
parentlib/sysfs: more robust sysfs_opendir() [coverity scan] (diff)
downloadkernel-qcow2-util-linux-17df84df275aa6ebf92dfb727a477bb8c2abe6eb.tar.gz
kernel-qcow2-util-linux-17df84df275aa6ebf92dfb727a477bb8c2abe6eb.tar.xz
kernel-qcow2-util-linux-17df84df275aa6ebf92dfb727a477bb8c2abe6eb.zip
switch_root: check open() return value [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r--sys-utils/switch_root.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c
index bcd801d5f..f0ef67745 100644
--- a/sys-utils/switch_root.c
+++ b/sys-utils/switch_root.c
@@ -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);