diff options
author | Greg Kurz <groug@kaod.org> | 2019-10-10 11:36:04 +0200 |
---|---|---|
committer | Greg Kurz <groug@kaod.org> | 2019-10-10 11:36:04 +0200 |
commit | c0da0cb7614db9a6ba6e8f00cea4c86844bb3e22 (patch) | |
tree | 5eea5b0668aeff1c08178a88f34b632080f21c50 /hw/9pfs/9p.c | |
parent | 870328335286385b5a78ba7d925b46dc5ba74d7f (diff) | |
download | qemu-c0da0cb7614db9a6ba6e8f00cea4c86844bb3e22.zip qemu-c0da0cb7614db9a6ba6e8f00cea4c86844bb3e22.tar.gz qemu-c0da0cb7614db9a6ba6e8f00cea4c86844bb3e22.tar.bz2 |
9p: Simplify error path of v9fs_device_realize_common()
Make v9fs_device_unrealize_common() idempotent and use it for rollback,
in order to reduce code duplication.
Signed-off-by: Greg Kurz <groug@kaod.org>
Diffstat (limited to 'hw/9pfs/9p.c')
-rw-r--r-- | hw/9pfs/9p.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index cf317bd..ba1ab92 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3637,27 +3637,23 @@ int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t, s->ctx.fst = &fse->fst; fsdev_throttle_init(s->ctx.fst); - v9fs_path_free(&path); - rc = 0; out: if (rc) { - if (s->ops && s->ops->cleanup && s->ctx.private) { - s->ops->cleanup(&s->ctx); - } - g_free(s->tag); - g_free(s->ctx.fs_root); - v9fs_path_free(&path); + v9fs_device_unrealize_common(s, NULL); } + v9fs_path_free(&path); return rc; } void v9fs_device_unrealize_common(V9fsState *s, Error **errp) { - if (s->ops->cleanup) { + if (s->ops && s->ops->cleanup) { s->ops->cleanup(&s->ctx); } - fsdev_throttle_cleanup(s->ctx.fst); + if (s->ctx.fst) { + fsdev_throttle_cleanup(s->ctx.fst); + } g_free(s->tag); g_free(s->ctx.fs_root); } |