[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 02/18] cadence_uart: Protect against transmit errors
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 02/18] cadence_uart: Protect against transmit errors |
Date: |
Mon, 27 Jun 2016 15:44:54 +0100 |
From: Alistair Francis <address@hidden>
If qemu_chr_fe_write() returns an error (represented by a negative
number) we should skip incrementing the count and initiating a
memmove().
Signed-off-by: Alistair Francis <address@hidden>
Reported-by: Peter Maydell <address@hidden>
Message-id: address@hidden
Reviewed-by: Peter Maydell <address@hidden>
Signed-off-by: Peter Maydell <address@hidden>
---
hw/char/cadence_uart.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c
index c856fc3..844542f 100644
--- a/hw/char/cadence_uart.c
+++ b/hw/char/cadence_uart.c
@@ -288,8 +288,11 @@ static gboolean cadence_uart_xmit(GIOChannel *chan,
GIOCondition cond,
}
ret = qemu_chr_fe_write(s->chr, s->tx_fifo, s->tx_count);
- s->tx_count -= ret;
- memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count);
+
+ if (ret >= 0) {
+ s->tx_count -= ret;
+ memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count);
+ }
if (s->tx_count) {
int r = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP,
--
1.9.1
- [Qemu-devel] [PULL 15/18] m25p80: Introduce configuration registers., (continued)
- [Qemu-devel] [PULL 15/18] m25p80: Introduce configuration registers., Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 08/18] palmetto-bmc: Configure the SCU's hardware strapping register, Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 05/18] arm: Re-enable tmp105 test, Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 18/18] m25p80: Fix WINBOND fast read command handling, Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 10/18] m25p80: Make a table for JEDEC ID., Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 13/18] m25p80: Add additional flash commands:, Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 12/18] m25p80: Introduce COLLECTING_VAR_LEN_DATA state., Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 04/18] cadence_gem: Set the last bit when wrap is set, Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 01/18] hw/intc/arm_gicv3: Add missing break, Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 11/18] m25p80: Allow more than four banks., Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 02/18] cadence_uart: Protect against transmit errors,
Peter Maydell <=
- [Qemu-devel] [PULL 17/18] m25p80: New flash devices., Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 06/18] hw/misc: Add a model for the ASPEED System Control Unit, Peter Maydell, 2016/06/27
- [Qemu-devel] [PULL 03/18] cadence_gem: Avoid infinite loops with a misconfigured buffer, Peter Maydell, 2016/06/27
- Re: [Qemu-devel] [PULL 00/18] target-arm queue, Peter Maydell, 2016/06/27