qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: elohimes@gmail.com
To: mst@redhat.com, stefanha@gmail.com, pbonzini@redhat.com, fam@euphon.net
Cc: Xie Yongji <xieyongji@baidu.com>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 1/2] vhost-scsi: Call virtio_scsi_common_unrealize() when device realize failed
Date: Wed, 17 Jul 2019 08:46:05 +0800	[thread overview]
Message-ID: <20190717004606.12444-1-xieyongji@baidu.com> (raw)

From: Xie Yongji <xieyongji@baidu.com>

This avoids memory leak when device hotplug is failed.

Signed-off-by: Xie Yongji <xieyongji@baidu.com>
---
 hw/scsi/vhost-scsi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c
index 4090f99ee4..c0dd9bdf89 100644
--- a/hw/scsi/vhost-scsi.c
+++ b/hw/scsi/vhost-scsi.c
@@ -210,7 +210,7 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
         if (err) {
             error_propagate(errp, err);
             error_free(vsc->migration_blocker);
-            goto close_fd;
+            goto free_virtio;
         }
     }
 
@@ -240,6 +240,10 @@ static void vhost_scsi_realize(DeviceState *dev, Error **errp)
         migrate_del_blocker(vsc->migration_blocker);
     }
     g_free(vsc->dev.vqs);
+ free_virtio:
+    err = NULL;
+    virtio_scsi_common_unrealize(dev, &err);
+    error_propagate(errp, err);
  close_fd:
     close(vhostfd);
     return;
-- 
2.17.1



             reply	other threads:[~2019-07-17  0:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-17  0:46 elohimes [this message]
2019-07-17  0:46 ` [Qemu-devel] [PATCH v2 2/2] vhost-user-scsi: Call virtio_scsi_common_unrealize() when device realize failed elohimes
2019-07-17  9:42   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190717004606.12444-1-xieyongji@baidu.com \
    --to=elohimes@gmail.com \
    --cc=fam@euphon.net \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    --cc=xieyongji@baidu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).