Patchwork [1/2] s390/sclpconsole: prevent char layer callback during initialization

login
register
mail settings
Submitter Christian Borntraeger
Date Feb. 5, 2013, 8:53 a.m.
Message ID <1360054405-2964-2-git-send-email-borntraeger@de.ibm.com>
Download mbox | patch
Permalink /patch/218179/
State New
Headers show

Comments

Christian Borntraeger - Feb. 5, 2013, 8:53 a.m.
Starting a qemu with an sclp console and pressing a key very early
can result in
"qemu-system-s390x: /home/cborntra/REPOS/qemu/hw/s390x/sclpconsole.c:60:
receive_from_chr_layer: Assertion `scon->iov' failed."

Lets make sure that the init process is finished, since the iov is
allocated after CHR_EVENT_OPENED by also checking for scon->iov.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
 hw/s390x/sclpconsole.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Patch

diff --git a/hw/s390x/sclpconsole.c b/hw/s390x/sclpconsole.c
index adc0ee8..effe511 100644
--- a/hw/s390x/sclpconsole.c
+++ b/hw/s390x/sclpconsole.c
@@ -44,12 +44,9 @@  typedef struct SCLPConsole {
 /* Return number of bytes that fit into iov buffer */
 static int chr_can_read(void *opaque)
 {
-    int can_read;
     SCLPConsole *scon = opaque;
 
-    can_read = SIZE_BUFFER_VT220 - scon->iov_data_len;
-
-    return can_read;
+    return scon->iov ? SIZE_BUFFER_VT220 - scon->iov_data_len : 0;
 }
 
 /* Receive n bytes from character layer, save in iov buffer,