[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 27/27] i.MX: Fix UART driver to work with unitialized
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 27/27] i.MX: Fix UART driver to work with unitialized "chardev" device |
Date: |
Thu, 13 Aug 2015 11:44:47 +0100 |
From: Jean-Christophe Dubois <address@hidden>
The "chardev" property initialization might have failed (for example because
there are not enough chardevs provided by QEMU).
The serial device emulator needs to be able to work with an uninitialized
(NULL) chardev device pointer.
This patch adds some missing tests on the chr pointer value before
using it.
Signed-off-by: Jean-Christophe Dubois <address@hidden>
Reviewed-by: Peter Crosthwaite <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
hw/char/imx_serial.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/char/imx_serial.c b/hw/char/imx_serial.c
index f9da59f..801156d 100644
--- a/hw/char/imx_serial.c
+++ b/hw/char/imx_serial.c
@@ -125,7 +125,9 @@ static uint64_t imx_serial_read(void *opaque, hwaddr offset,
s->usr2 &= ~USR2_RDR;
s->uts1 |= UTS1_RXEMPTY;
imx_update(s);
- qemu_chr_accept_input(s->chr);
+ if (s->chr) {
+ qemu_chr_accept_input(s->chr);
+ }
}
return c;
@@ -212,7 +214,9 @@ static void imx_serial_write(void *opaque, hwaddr offset,
}
if (value & UCR2_RXEN) {
if (!(s->ucr2 & UCR2_RXEN)) {
- qemu_chr_accept_input(s->chr);
+ if (s->chr) {
+ qemu_chr_accept_input(s->chr);
+ }
}
}
s->ucr2 = value & 0xffff;
--
1.9.1
- [Qemu-devel] [PULL 12/27] i.MX: Fix Coding style for AVIC emulator., (continued)
- [Qemu-devel] [PULL 12/27] i.MX: Fix Coding style for AVIC emulator., Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 15/27] i.MX: Split EPIT emulator in a header file and a source file, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 17/27] i.MX: Split GPT emulator in a header file and a source file, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 24/27] target-arm: Add AArch32 banked register access to secure physical timer, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 10/27] i.MX:Fix Coding style for UART emulator., Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 20/27] hw/arm/gic: Kill code duplication, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 06/27] hw/arm/virt: Replace magic IRQ constants with macros, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 19/27] Merge memory_region_init_reservation() into memory_region_init_io(), Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 02/27] target-arm: Add CNTHCTL_EL2, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 14/27] i.MX: Fix Coding style for CCM emulator, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 27/27] i.MX: Fix UART driver to work with unitialized "chardev" device,
Peter Maydell <=
- [Qemu-devel] [PULL 07/27] hw/arm/virt: Connect the Hypervisor timer, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 11/27] i.MX: Split AVIC emulator in a header file and a source file, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 03/27] target-arm: Rename and move gt_cnt_reset, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 13/27] i.MX: Split CCM emulator in a header file and a source file, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 08/27] i.MX: Split UART emulator in a header file and a source file, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 05/27] target-arm: Add the Hypervisor timer, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 21/27] Introduce gic_class_name() instead of repeating condition, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 25/27] hw/arm/virt: Wire up secure timer interrupt, Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 09/27] i.MX: Move serial initialization to init/realize of DeviceClass., Peter Maydell, 2015/08/13
- [Qemu-devel] [PULL 26/27] hw/cpu/a15mpcore: Wire up hyp and secure physical timer interrupts, Peter Maydell, 2015/08/13