[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/10] chardev/char.c: Always pass id to chardev_new
From: |
marcandre . lureau |
Subject: |
[PULL 08/10] chardev/char.c: Always pass id to chardev_new |
Date: |
Sun, 28 Mar 2021 22:45:31 +0400 |
From: Lukas Straub <lukasstraub2@web.de>
Always pass the id to chardev_new, since it is needed to register
the yank instance for the chardev. Also, after checking that
nothing calls chardev_new with id=NULL, assert() that id!=NULL.
This fixes a crash when using chardev-change to change a chardev
to chardev-socket, which attempts to register a yank instance.
This in turn tries to dereference the NULL-pointer.
Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Tested-by: Li Zhang <li.zhang@cloud.ionos.com>
Message-Id:
<3e669b6c160aa7278e37c4d95e0445574f96c7b7.1616794852.git.lukasstraub2@web.de>
---
chardev/char.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/chardev/char.c b/chardev/char.c
index 48f321b3e1..75993f903f 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -967,6 +967,7 @@ static Chardev *chardev_new(const char *id, const char
*typename,
bool be_opened = true;
assert(g_str_has_prefix(typename, "chardev-"));
+ assert(id);
obj = object_new(typename);
chr = CHARDEV(obj);
@@ -1095,12 +1096,11 @@ ChardevReturn *qmp_chardev_change(const char *id,
ChardevBackend *backend,
return NULL;
}
- chr_new = chardev_new(NULL, object_class_get_name(OBJECT_CLASS(cc)),
+ chr_new = chardev_new(id, object_class_get_name(OBJECT_CLASS(cc)),
backend, chr->gcontext, errp);
if (!chr_new) {
return NULL;
}
- chr_new->label = g_strdup(id);
if (chr->be_open && !chr_new->be_open) {
qemu_chr_be_event(chr, CHR_EVENT_CLOSED);
--
2.29.0
- [PULL 00/10] For 6.0 patches, marcandre . lureau, 2021/03/28
- [PULL 01/10] util: fix use-after-free in module_load_one, marcandre . lureau, 2021/03/28
- [PULL 02/10] dbus-vmstate: Increase the size of input stream buffer used during load, marcandre . lureau, 2021/03/28
- [PULL 03/10] sphinx: adopt kernel readthedoc theme, marcandre . lureau, 2021/03/28
- [PULL 04/10] docs: simplify each section title, marcandre . lureau, 2021/03/28
- [PULL 05/10] yank: Remove dependency on qiochannel, marcandre . lureau, 2021/03/28
- [PULL 06/10] yank: Always link full yank code, marcandre . lureau, 2021/03/28
- [PULL 07/10] chardev/char.c: Move object_property_try_add_child out of chardev_new, marcandre . lureau, 2021/03/28
- [PULL 08/10] chardev/char.c: Always pass id to chardev_new,
marcandre . lureau <=
- [PULL 09/10] chardev: Fix yank with the chardev-change case, marcandre . lureau, 2021/03/28
- [PULL 10/10] tests: Add tests for yank with the chardev-change case, marcandre . lureau, 2021/03/28
- Re: [PULL 00/10] For 6.0 patches, no-reply, 2021/03/28
- Re: [PULL 00/10] For 6.0 patches, Peter Maydell, 2021/03/29
- Re: [PULL 00/10] For 6.0 patches, Marc-André Lureau, 2021/03/29
- Re: [PULL 00/10] For 6.0 patches, Peter Maydell, 2021/03/29
- Re: [PULL 00/10] For 6.0 patches, Marc-André Lureau, 2021/03/29
- Re: [PULL 00/10] For 6.0 patches, Peter Maydell, 2021/03/29
- Re: [PULL 00/10] For 6.0 patches, Marc-André Lureau, 2021/03/30
- Re: [PULL 00/10] For 6.0 patches, Peter Maydell, 2021/03/30