summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Kurz <groug@kaod.org>2017-03-06 17:34:01 +0100
committerMichael Roth <mdroth@linux.vnet.ibm.com>2017-03-16 12:08:47 -0500
commit059f751ec27279775f54bac52a2eb35ece6d16cf (patch)
tree1154b8835d6cb321925678df3111bca537682305
parentbb07a379b5888b378a97d1803d2808fa0388a623 (diff)
downloadqemu-059f751ec27279775f54bac52a2eb35ece6d16cf.tar.gz
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 <groug@kaod.org> Reviewed-by: Daniel P. berrange <berrange@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> (cherry picked from commit 23da0145cc4be66fdb1033f951dbbf140f457896) Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
-rw-r--r--hw/9pfs/9p-local.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index c5f7dcd131..09b9b576c0 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;