aboutsummaryrefslogtreecommitdiff
path: root/hw/9pfs
diff options
context:
space:
mode:
authorGreg Kurz <groug@kaod.org>2017-03-06 17:34:01 +0100
committerGreg Kurz <groug@kaod.org>2017-03-06 17:34:01 +0100
commit23da0145cc4be66fdb1033f951dbbf140f457896 (patch)
tree67080b3a4c82e0ebb47265d8c4c99074c146a6f9 /hw/9pfs
parentfaab207f115cf9738f110cb088ab35a4b7aef73a (diff)
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>
Diffstat (limited to 'hw/9pfs')
-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 09f6a46d61..6d16c4a065 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1053,6 +1053,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;