qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit@kernel.org>
To: "Michael S. Tsirkin" <mst@redhat.com>,
	Pan Nengyuan <pannengyuan@huawei.com>
Cc: lvivier@redhat.com, zhang.zhanghailiang@huawei.com,
	qemu-devel@nongnu.org, pbonzini@redhat.com,
	euler.robot@huawei.com, marcandre.lureau@redhat.com
Subject: Re: [PATCH v3] virtio-serial-bus: Plug memory leak on realize() error paths
Date: Mon, 09 Mar 2020 09:18:43 +0100	[thread overview]
Message-ID: <aa7ae0db0b16efc14f22954c244c0673ceb21f59.camel@kernel.org> (raw)
In-Reply-To: <20200309030140-mutt-send-email-mst@kernel.org>

On Mon, 2020-03-09 at 03:02 -0400, Michael S. Tsirkin wrote:
> On Mon, Mar 09, 2020 at 10:17:38AM +0800, Pan Nengyuan wrote:
> > We neglect to free port->bh on the error paths.  Fix that.
> > Reproducer:
> >     {'execute': 'device_add', 'arguments': {'id':
> > 'virtio_serial_pci0', 'driver': 'virtio-serial-pci', 'bus':
> > 'pci.0', 'addr': '0x5'}, 'id': 'yVkZcGgV'}
> >     {'execute': 'device_add', 'arguments': {'id': 'port1',
> > 'driver': 'virtserialport', 'name': 'port1', 'chardev': 'channel1',
> > 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': '3dXdUgJA'}
> >     {'execute': 'device_add', 'arguments': {'id': 'port2',
> > 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2',
> > 'bus': 'virtio_serial_pci0.0', 'nr': 1}, 'id': 'qLzcCkob'}
> >     {'execute': 'device_add', 'arguments': {'id': 'port2',
> > 'driver': 'virtserialport', 'name': 'port2', 'chardev': 'channel2',
> > 'bus': 'virtio_serial_pci0.0', 'nr': 2}, 'id': 'qLzcCkob'}
> > 
> > The leak stack:
> > Direct leak of 40 byte(s) in 1 object(s) allocated from:
> >     #0 0x7f04a8008ae8 in __interceptor_malloc
> > (/lib64/libasan.so.5+0xefae8)
> >     #1 0x7f04a73cf1d5 in g_malloc (/lib64/libglib-2.0.so.0+0x531d5)
> >     #2 0x56273eaee484 in aio_bh_new
> > /mnt/sdb/backup/qemu/util/async.c:125
> >     #3 0x56273eafe9a8 in qemu_bh_new
> > /mnt/sdb/backup/qemu/util/main-loop.c:532
> >     #4 0x56273d52e62e in virtser_port_device_realize
> > /mnt/sdb/backup/qemu/hw/char/virtio-serial-bus.c:946
> >     #5 0x56273dcc5040 in device_set_realized
> > /mnt/sdb/backup/qemu/hw/core/qdev.c:891
> >     #6 0x56273e5ebbce in property_set_bool
> > /mnt/sdb/backup/qemu/qom/object.c:2238
> >     #7 0x56273e5e5a9c in object_property_set
> > /mnt/sdb/backup/qemu/qom/object.c:1324
> >     #8 0x56273e5ef5f8 in object_property_set_qobject
> > /mnt/sdb/backup/qemu/qom/qom-qobject.c:26
> >     #9 0x56273e5e5e6a in object_property_set_bool
> > /mnt/sdb/backup/qemu/qom/object.c:1390
> >     #10 0x56273daa40de in qdev_device_add
> > /mnt/sdb/backup/qemu/qdev-monitor.c:680
> >     #11 0x56273daa53e9 in qmp_device_add /mnt/sdb/backup/qemu/qdev-
> > monitor.c:805
> > 
> > Fixes: 199646d81522509ac2dba6d28c31e8c7d807bc93
> > Reported-by: Euler Robot <euler.robot@huawei.com>
> > Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> > Reviewed-by: Markus Armbruster <armbru@redhat.com>
> > Reviewed-by: Amit Shah <amit@kernel.org>
> > ---
> > v1->v2:
> > - simply create port->bh last in virtser_port_device_realize() to
> > fix memleaks.(Suggested by Markus Armbruster)
> 
> 
> Markus, Amit do your Reviewed-by tags still stand?

Yep, the review was for v2.




  parent reply	other threads:[~2020-03-09  8:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09  2:17 [PATCH v3] virtio-serial-bus: Plug memory leak on realize() error paths Pan Nengyuan
2020-03-09  2:27 ` no-reply
2020-03-09  7:02 ` Michael S. Tsirkin
2020-03-09  8:16   ` Markus Armbruster
2020-03-09  8:18   ` Amit Shah [this message]
2020-03-09  7:55 ` Laurent Vivier

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=aa7ae0db0b16efc14f22954c244c0673ceb21f59.camel@kernel.org \
    --to=amit@kernel.org \
    --cc=euler.robot@huawei.com \
    --cc=lvivier@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pannengyuan@huawei.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhang.zhanghailiang@huawei.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).