From: Markus Armbruster <armbru@redhat.com>
To: marcandre.lureau@redhat.com
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-2.6] ivshmem: fix crash with ivshmem-plain
Date: Tue, 12 Apr 2016 16:51:10 +0200 [thread overview]
Message-ID: <87vb3mkhi9.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <1460468317-11863-1-git-send-email-marcandre.lureau@redhat.com> (marcandre lureau's message of "Tue, 12 Apr 2016 15:38:37 +0200")
marcandre.lureau@redhat.com writes:
> From: Marc-André Lureau <marcandre.lureau@redhat.com>
>
> "qemu -device ivshmem-plain" will crash, because it doesn't check that
> 'memdev' was provided.
>
> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Oww!
> ---
> hw/misc/ivshmem.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
> index 08bf5c6..fae4d08 100644
> --- a/hw/misc/ivshmem.c
> +++ b/hw/misc/ivshmem.c
> @@ -868,7 +868,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
>
> s->ivshmem_bar2 = host_memory_backend_get_memory(s->hostmem,
> &error_abort);
> - } else {
> + } else if (s->server_chr) {
I'd simply stick
assert(s->server_chr)
here.
> IVSHMEM_DPRINTF("using shared memory server (socket = %s)\n",
> s->server_chr->filename);
>
> @@ -899,6 +899,8 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
> error_setg(errp, "failed to initialize interrupts");
> return;
> }
> + } else {
> + g_assert_not_reached();
> }
>
> vmstate_register_ram(s->ivshmem_bar2, DEVICE(s));
> @@ -1048,10 +1050,25 @@ static void ivshmem_plain_init(Object *obj)
> &error_abort);
> }
>
> +static void ivshmem_plain_realize(PCIDevice *dev, Error **errp)
> +{
> + IVShmemState *s = IVSHMEM_COMMON(dev);
> +
> + if (!s->hostmem) {
> + error_setg(errp, "You must specify a 'memdev'");
> + return;
> + }
> +
> + ivshmem_common_realize(dev, errp);
> +}
> +
> +
> static void ivshmem_plain_class_init(ObjectClass *klass, void *data)
> {
> DeviceClass *dc = DEVICE_CLASS(klass);
> + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
>
> + k->realize = ivshmem_plain_realize;
> dc->props = ivshmem_plain_properties;
> dc->vmsd = &ivshmem_plain_vmsd;
> }
Same bug in ivshmem-doorbell. Care to fix that, too?
prev parent reply other threads:[~2016-04-12 14:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-12 13:38 [Qemu-devel] [PATCH for-2.6] ivshmem: fix crash with ivshmem-plain marcandre.lureau
2016-04-12 14:51 ` Markus Armbruster [this message]
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=87vb3mkhi9.fsf@dusky.pond.sub.org \
--to=armbru@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.