qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/display/xlnx_dp: fix overflow in xlnx_dp_aux_push_rx_fifo()
@ 2023-01-05 12:57 Qiang Liu
  0 siblings, 0 replies; only message in thread
From: Qiang Liu @ 2023-01-05 12:57 UTC (permalink / raw)
  To: qemu-devel
  Cc: Qiang Liu, Alistair Francis, Edgar E. Iglesias, Peter Maydell,
	open list:Xilinx ZynqMP and...

Check s->rx_fifo before pushing data into it.

Fixes: 58ac482a66de ("introduce xlnx-dp")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1419
Reported-by: Qiang Liu <cyruscyliu@gmail.com>
Signed-off-by: Qiang Liu <cyruscyliu@gmail.com>
---
 hw/display/xlnx_dp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c
index 322e2faadd..972473d94f 100644
--- a/hw/display/xlnx_dp.c
+++ b/hw/display/xlnx_dp.c
@@ -508,6 +508,10 @@ static void xlnx_dp_aux_set_command(XlnxDPState *s, uint32_t value)
     case READ_AUX:
     case READ_I2C:
     case READ_I2C_MOT:
+        if (nbytes > fifo8_num_free(&s->rx_fifo)) {
+            qemu_log_mask(LOG_GUEST_ERROR, "xlnx_dp: RX length > available fifo data length");
+            nbytes = fifo8_num_free(&s->rx_fifo);
+        }
         s->core_registers[DP_AUX_REPLY_CODE] = aux_request(s->aux_bus, cmd,
                                                xlnx_dp_aux_get_address(s),
                                                nbytes, buf);
-- 
2.25.1



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-01-05 12:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-05 12:57 [PATCH] hw/display/xlnx_dp: fix overflow in xlnx_dp_aux_push_rx_fifo() Qiang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).