From: Greg Kurz Date: Mon, 6 Mar 2017 16:34:01 +0000 (+0100) Subject: 9pfs: fail local_statfs() earlier X-Git-Tag: v2.8.1~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=059f751ec27279775f54bac52a2eb35ece6d16cf;p=thirdparty%2Fqemu.git 9pfs: fail local_statfs() earlier If we cannot open the given path, we can return right away instead of passing -1 to fstatfs() and close(). This will make Coverity happy. (Coverity issue CID1371729) Signed-off-by: Greg Kurz Reviewed-by: Daniel P. berrange Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé (cherry picked from commit 23da0145cc4be66fdb1033f951dbbf140f457896) Signed-off-by: Greg Kurz Signed-off-by: Michael Roth --- diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index c5f7dcd131e..09b9b576c01 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1054,6 +1054,9 @@ static int local_statfs(FsContext *s, V9fsPath *fs_path, struct statfs *stbuf) int fd, ret; fd = local_open_nofollow(s, fs_path->data, O_RDONLY, 0); + if (fd == -1) { + return -1; + } ret = fstatfs(fd, stbuf); close_preserve_errno(fd); return ret;