]> git.proxmox.com Git - mirror_qemu.git/commitdiff
i.MX: Fix UART driver to work with unitialized "chardev" device
authorJean-Christophe Dubois <jcd@tribudubois.net>
Thu, 13 Aug 2015 10:26:22 +0000 (11:26 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 13 Aug 2015 10:26:22 +0000 (11:26 +0100)
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>
hw/char/imx_serial.c

index f9da59fd6351379055d407804a728d3f77d49f0b..801156db2dcf6ecc77bfac11d04c0ec3b8501ec0 100644 (file)
@@ -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;