From: Karel Zak Date: Fri, 7 Sep 2012 11:02:42 +0000 (+0200) Subject: switch_root: check open() return value [coverity scan] X-Git-Tag: v2.23-rc1~713 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=17df84df275aa6ebf92dfb727a477bb8c2abe6eb;p=thirdparty%2Futil-linux.git switch_root: check open() return value [coverity scan] Signed-off-by: Karel Zak --- diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index bcd801d5fb..f0ef67745f 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);