[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 15/16] chardev/char-fe: Allow NULL chardev in qemu_ch
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 15/16] chardev/char-fe: Allow NULL chardev in qemu_chr_fe_init() |
Date: |
Mon, 26 Mar 2018 15:36:42 +0200 |
From: Peter Maydell <address@hidden>
All the functions in char-fe.c handle the CharBackend
having a NULL Chardev pointer, which means that the
backend exists but is not connected to anything. The
exception is qemu_chr_fe_init(), which will crash if
passed a NULL Chardev pointer argument. This can happen
for various boards if they're started with 'nodefaults':
arm-softmmu/qemu-system-arm -S -nodefaults -M cubieboard
riscv32-softmmu/qemu-system-riscv32 -nodefaults -M sifive_e
Make qemu_chr_fe_init() accept a NULL chardev. This allows
UART models to handle NULL chardev properties without
generally needing to special case them or to manually
create a NullChardev.
Reported-by: Thomas Huth <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
chardev/char-fe.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/chardev/char-fe.c b/chardev/char-fe.c
index 392db78..b1f228e 100644
--- a/chardev/char-fe.c
+++ b/chardev/char-fe.c
@@ -198,19 +198,21 @@ bool qemu_chr_fe_init(CharBackend *b, Chardev *s, Error
**errp)
{
int tag = 0;
- if (CHARDEV_IS_MUX(s)) {
- MuxChardev *d = MUX_CHARDEV(s);
+ if (s) {
+ if (CHARDEV_IS_MUX(s)) {
+ MuxChardev *d = MUX_CHARDEV(s);
+
+ if (d->mux_cnt >= MAX_MUX) {
+ goto unavailable;
+ }
- if (d->mux_cnt >= MAX_MUX) {
+ d->backends[d->mux_cnt] = b;
+ tag = d->mux_cnt++;
+ } else if (s->be) {
goto unavailable;
+ } else {
+ s->be = b;
}
-
- d->backends[d->mux_cnt] = b;
- tag = d->mux_cnt++;
- } else if (s->be) {
- goto unavailable;
- } else {
- s->be = b;
}
b->fe_open = false;
--
1.8.3.1
- [Qemu-devel] [PULL 07/16] hw/audio: Fix crashes when devices are used on ISA bus without DMA, (continued)
- [Qemu-devel] [PULL 07/16] hw/audio: Fix crashes when devices are used on ISA bus without DMA, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 06/16] fdc: Exit if ISA controller does not support DMA, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 08/16] scripts/device-crash-test: Remove fixed isapc-with-iommu entry, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 09/16] vhost-user-test: do not hang if chardev creation failed, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 11/16] tcg: Really fix cpu_io_recompile, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 12/16] chardev-socket: remove useless if, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 13/16] scsi: turn "is this a SCSI device?" into a conditional hint, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 14/16] iothread: fix breakage on windows, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 15/16] chardev/char-fe: Allow NULL chardev in qemu_chr_fe_init(),
Paolo Bonzini <=
- [Qemu-devel] [PULL 10/16] vhost-user-test: add back memfd check, Paolo Bonzini, 2018/03/26
- [Qemu-devel] [PULL 16/16] qemu-pr-helper: Actually allow users to specify pidfile, Paolo Bonzini, 2018/03/26
- Re: [Qemu-devel] [PULL 00/16] Misc fixes for QEMU 2.12.0-rc1, Peter Maydell, 2018/03/27