aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/virtio-9p.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/hw/virtio-9p.c b/hw/virtio-9p.c
index 3b2d49cde0..3379a3029b 100644
--- a/hw/virtio-9p.c
+++ b/hw/virtio-9p.c
@@ -1760,8 +1760,10 @@ static void v9fs_post_lcreate(V9fsState *s, V9fsLcreateState *vs, int err)
err = vs->offset;
} else {
vs->fidp->fid_type = P9_FID_NONE;
- close(vs->fidp->fs.fd);
err = -errno;
+ if (vs->fidp->fs.fd > 0) {
+ close(vs->fidp->fs.fd);
+ }
}
complete_pdu(s, vs->pdu, err);