From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKoF0-0007UL-ET for qemu-devel@nongnu.org; Thu, 30 Jul 2015 09:51:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZKoEt-0000md-Pe for qemu-devel@nongnu.org; Thu, 30 Jul 2015 09:51:22 -0400 Received: from mail-wi0-x22a.google.com ([2a00:1450:400c:c05::22a]:37986) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZKoEt-0000mB-Hl for qemu-devel@nongnu.org; Thu, 30 Jul 2015 09:51:15 -0400 Received: by wibxm9 with SMTP id xm9so69787260wib.1 for ; Thu, 30 Jul 2015 06:51:14 -0700 (PDT) Sender: Paolo Bonzini References: <1438262999-287627-1-git-send-email-imammedo@redhat.com> From: Paolo Bonzini Message-ID: <55BA2BD1.8050401@redhat.com> Date: Thu, 30 Jul 2015 15:51:13 +0200 MIME-Version: 1.0 In-Reply-To: <1438262999-287627-1-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] vhost/scsi: call vhost_dev_cleanup() at unrealize() time List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: lina.lulina@huawei.com, arei.gonglei@huawei.com, mst@redhat.com On 30/07/2015 15:29, Igor Mammedov wrote: > vhost-scsi calls vhost_dev_init() at realize() time > but forgets to call it's counterpart vhost_dev_cleanup() > at unrealize() time. > > Calling it should fix leaking of memory table and > mem_sections table in vhost device. And also unregister > vhost's memory listerner to prevent access from > memory core to freed memory. > > Signed-off-by: Igor Mammedov > --- > hw/scsi/vhost-scsi.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/scsi/vhost-scsi.c b/hw/scsi/vhost-scsi.c > index a69918b..0dd57ff 100644 > --- a/hw/scsi/vhost-scsi.c > +++ b/hw/scsi/vhost-scsi.c > @@ -277,6 +277,7 @@ static void vhost_scsi_unrealize(DeviceState *dev, Error **errp) > /* This will stop vhost backend. */ > vhost_scsi_set_status(vdev, 0); > > + vhost_dev_cleanup(&s->dev); > g_free(s->dev.vqs); > > virtio_scsi_common_unrealize(dev, errp); > Applied to scsi-next, thanks. Paolo