diff mbox series

vhost: fix memory leak in vhost_user_scsi_realize

Message ID 1556608500-12183-1-git-send-email-wangjie88@huawei.com (mailing list archive)
State New, archived
Headers show
Series vhost: fix memory leak in vhost_user_scsi_realize | expand

Commit Message

Jie Wang April 30, 2019, 7:15 a.m. UTC
fix memory leak in vhost_user_scsi_realize

Signed-off-by: Jie Wang <wangjie88@huawei.com>
---
 hw/scsi/vhost-user-scsi.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Stefan Hajnoczi May 1, 2019, 4:40 p.m. UTC | #1
On Tue, Apr 30, 2019 at 03:15:00PM +0800, Jie Wang wrote:
> fix memory leak in vhost_user_scsi_realize
> 
> Signed-off-by: Jie Wang <wangjie88@huawei.com>
> ---
>  hw/scsi/vhost-user-scsi.c | 3 +++
>  1 file changed, 3 insertions(+)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Jie Wang May 29, 2019, 12:12 p.m. UTC | #2
On 2019/5/2 0:40, Stefan Hajnoczi wrote:
> On Tue, Apr 30, 2019 at 03:15:00PM +0800, Jie Wang wrote:
>> fix memory leak in vhost_user_scsi_realize
>>
>> Signed-off-by: Jie Wang <wangjie88@huawei.com>
>> ---
>>  hw/scsi/vhost-user-scsi.c | 3 +++
>>  1 file changed, 3 insertions(+)
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox series

Patch

diff --git a/hw/scsi/vhost-user-scsi.c b/hw/scsi/vhost-user-scsi.c
index 8b1e6876db..a9fd8ea305 100644
--- a/hw/scsi/vhost-user-scsi.c
+++ b/hw/scsi/vhost-user-scsi.c
@@ -69,6 +69,7 @@  static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
     VirtIOSCSICommon *vs = VIRTIO_SCSI_COMMON(dev);
     VHostUserSCSI *s = VHOST_USER_SCSI(dev);
     VHostSCSICommon *vsc = VHOST_SCSI_COMMON(s);
+    struct vhost_virtqueue *vqs = NULL;
     Error *err = NULL;
     int ret;
 
@@ -93,6 +94,7 @@  static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
     vsc->dev.vqs = g_new(struct vhost_virtqueue, vsc->dev.nvqs);
     vsc->dev.vq_index = 0;
     vsc->dev.backend_features = 0;
+    vqs = vsc->dev.vqs;
 
     ret = vhost_dev_init(&vsc->dev, &s->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0);
@@ -100,6 +102,7 @@  static void vhost_user_scsi_realize(DeviceState *dev, Error **errp)
         error_setg(errp, "vhost-user-scsi: vhost initialization failed: %s",
                    strerror(-ret));
         vhost_user_cleanup(&s->vhost_user);
+        g_free(vqs);
         return;
     }