Skip to contentSkip to conversation

hw/display/xlnx_dp: fix underflow in xlnx_dp_aux_pop_tx_fifo()

PATCH New Qiang Liu 1 participant 1 message Jan 5, 2023

lore
Share & tools
lore

Qiang Liu

author
#0 lore raw

PATCH 1/1 hw/display/xlnx_dp: fix underflow in xlnx_dp_aux_pop_tx_fifo()

Fixes 58ac482a66de ("introduce xlnx-dp")

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1418

---
 hw/display/xlnx_dp.c | 4 ++++
 1 file changed, 4 insertions(+)
hw/display/xlnx_dp.c +4 -0
index 407518c870..322e2faadd 100644
@@ -520,6 +520,10 @@ static void xlnx_dp_aux_set_command(XlnxDPState *s, uint32_t value)
     case WRITE_AUX:
     case WRITE_I2C:
     case WRITE_I2C_MOT:
+        if (nbytes > fifo8_num_used(&s->tx_fifo)) {
+            qemu_log_mask(LOG_GUEST_ERROR, "xlnx_dp: TX length > fifo data length");
+            nbytes = fifo8_num_used(&s->tx_fifo);
+        }
         for (i = 0; i < nbytes; i++) {
             buf[i] = xlnx_dp_aux_pop_tx_fifo(s);
         }
Signature · 1 line
2.25.1