diff options
author | Jean-Christophe Dubois <jcd@tribudubois.net> | 2015-08-13 11:26:22 +0100 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2015-08-13 11:26:22 +0100 |
commit | f7a6785e12d834d05200b0595070db453344b25d (patch) | |
tree | 07cdae6f448514ba854aa34e5f774b03a00e78b7 /hw/char | |
parent | 5dfaa75b4d96fe88858a98d947b97e697e2811e6 (diff) | |
download | qemu-f7a6785e12d834d05200b0595070db453344b25d.zip qemu-f7a6785e12d834d05200b0595070db453344b25d.tar.gz qemu-f7a6785e12d834d05200b0595070db453344b25d.tar.bz2 |
i.MX: Fix UART driver to work with unitialized "chardev" device
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 <jcd@tribudubois.net>
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Message-id: 1438342461-18967-1-git-send-email-jcd@tribudubois.net
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/char')
-rw-r--r-- | hw/char/imx_serial.c | 8 |
1 files 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; |