[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/28] 9pfs: remove side-effects in local_init()
From: |
Greg Kurz |
Subject: |
[Qemu-devel] [PULL 02/28] 9pfs: remove side-effects in local_init() |
Date: |
Tue, 28 Feb 2017 11:30:14 +0100 |
If this function fails, it should not modify *ctx.
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
---
hw/9pfs/9p-local.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c
index 7de07e1ba67f..4a8e628117ae 100644
--- a/hw/9pfs/9p-local.c
+++ b/hw/9pfs/9p-local.c
@@ -1168,9 +1168,25 @@ static int local_ioc_getversion(FsContext *ctx, V9fsPath
*path,
static int local_init(FsContext *ctx)
{
- int err = 0;
struct statfs stbuf;
+#ifdef FS_IOC_GETVERSION
+ /*
+ * use ioc_getversion only if the ioctl is definied
+ */
+ if (statfs(ctx->fs_root, &stbuf) < 0) {
+ return -1;
+ }
+ switch (stbuf.f_type) {
+ case EXT2_SUPER_MAGIC:
+ case BTRFS_SUPER_MAGIC:
+ case REISERFS_SUPER_MAGIC:
+ case XFS_SUPER_MAGIC:
+ ctx->exops.get_st_gen = local_ioc_getversion;
+ break;
+ }
+#endif
+
if (ctx->export_flags & V9FS_SM_PASSTHROUGH) {
ctx->xops = passthrough_xattr_ops;
} else if (ctx->export_flags & V9FS_SM_MAPPED) {
@@ -1185,23 +1201,8 @@ static int local_init(FsContext *ctx)
ctx->xops = passthrough_xattr_ops;
}
ctx->export_flags |= V9FS_PATHNAME_FSCONTEXT;
-#ifdef FS_IOC_GETVERSION
- /*
- * use ioc_getversion only if the iocl is definied
- */
- err = statfs(ctx->fs_root, &stbuf);
- if (!err) {
- switch (stbuf.f_type) {
- case EXT2_SUPER_MAGIC:
- case BTRFS_SUPER_MAGIC:
- case REISERFS_SUPER_MAGIC:
- case XFS_SUPER_MAGIC:
- ctx->exops.get_st_gen = local_ioc_getversion;
- break;
- }
- }
-#endif
- return err;
+
+ return 0;
}
static int local_parse_opts(QemuOpts *opts, struct FsDriverEntry *fse)
--
2.7.4
- [Qemu-devel] [PULL 00/28] 9p CVE-2016-9602 fixes 2017-02-28 for 2.9 soft freeze, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 03/28] 9pfs: remove side-effects in local_open() and local_opendir(), Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 01/28] 9pfs: local: move xattr security ops to 9p-xattr.c, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 02/28] 9pfs: remove side-effects in local_init(),
Greg Kurz <=
- [Qemu-devel] [PULL 05/28] 9pfs: local: keep a file descriptor on the shared folder, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 06/28] 9pfs: local: open/opendir: don't follow symlinks, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 04/28] 9pfs: introduce relative_openat_nofollow() helper, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 09/28] 9pfs: local: lsetxattr: don't follow symlinks, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 07/28] 9pfs: local: lgetxattr: don't follow symlinks, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 08/28] 9pfs: local: llistxattr: don't follow symlinks, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 12/28] 9pfs: local: remove: don't follow symlinks, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 13/28] 9pfs: local: utimensat: don't follow symlinks, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 11/28] 9pfs: local: unlinkat: don't follow symlinks, Greg Kurz, 2017/02/28
- [Qemu-devel] [PULL 14/28] 9pfs: local: statfs: don't follow symlinks, Greg Kurz, 2017/02/28