From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51918) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YY8VV-0004LT-3i for qemu-devel@nongnu.org; Wed, 18 Mar 2015 03:35:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YY8VR-00042q-UO for qemu-devel@nongnu.org; Wed, 18 Mar 2015 03:35:13 -0400 Received: from mail-wg0-x235.google.com ([2a00:1450:400c:c00::235]:36294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YY8VR-00040z-HT for qemu-devel@nongnu.org; Wed, 18 Mar 2015 03:35:09 -0400 Received: by wgra20 with SMTP id a20so27480478wgr.3 for ; Wed, 18 Mar 2015 00:35:09 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <55092AA9.8030303@redhat.com> Date: Wed, 18 Mar 2015 08:35:05 +0100 From: Paolo Bonzini MIME-Version: 1.0 References: <1426671732-80213-1-git-send-email-subo7@huawei.com> In-Reply-To: <1426671732-80213-1-git-send-email-subo7@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-scsi-dataplane: fix memory leak in virtio_scsi_vring_init List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Bo Su , qemu-devel@nongnu.org On 18/03/2015 10:42, Bo Su wrote: > if k->set_host_notifier failed, VirtIOSCSIVring *r will leak > > Signed-off-by: Bo Su > --- > hw/scsi/virtio-scsi-dataplane.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplane.c > index 3f40ff0..c069cd7 100644 > --- a/hw/scsi/virtio-scsi-dataplane.c > +++ b/hw/scsi/virtio-scsi-dataplane.c > @@ -45,7 +45,7 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s, > { > BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(s))); > VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(qbus); > - VirtIOSCSIVring *r = g_slice_new(VirtIOSCSIVring); > + VirtIOSCSIVring *r; > int rc; > > /* Set up virtqueue notify */ > @@ -56,6 +56,8 @@ static VirtIOSCSIVring *virtio_scsi_vring_init(VirtIOSCSI *s, > s->dataplane_fenced = true; > return NULL; > } > + > + r = g_slice_new(VirtIOSCSIVring); > r->host_notifier = *virtio_queue_get_host_notifier(vq); > r->guest_notifier = *virtio_queue_get_guest_notifier(vq); > aio_set_event_notifier(s->ctx, &r->host_notifier, handler); > Thanks, queued for 2.3. Paolo