[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL V2 08/10] hw/net/can/xlnx-zynqmp-can: fix assertion failures in tr
From: |
Jason Wang |
Subject: |
[PULL V2 08/10] hw/net/can/xlnx-zynqmp-can: fix assertion failures in transfer_fifo() |
Date: |
Thu, 16 Feb 2023 13:24:22 +0800 |
From: Qiang Liu <cyruscyliu@gmail.com>
Check fifos before poping data from and pushing data into it.
Fixes: 98e5d7a2b726 ("hw/net/can: Introduce Xilinx ZynqMP CAN controller")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1425
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1427
Reported-by: Qiang Liu <cyruscyliu@gmail.com>
Signed-off-by: Qiang Liu <cyruscyliu@gmail.com>
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/can/xlnx-zynqmp-can.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/hw/net/can/xlnx-zynqmp-can.c b/hw/net/can/xlnx-zynqmp-can.c
index e93e6c5..8a56734 100644
--- a/hw/net/can/xlnx-zynqmp-can.c
+++ b/hw/net/can/xlnx-zynqmp-can.c
@@ -451,6 +451,12 @@ static void transfer_fifo(XlnxZynqMPCANState *s, Fifo32
*fifo)
}
while (!fifo32_is_empty(fifo)) {
+ if (fifo32_num_used(fifo) < CAN_FRAME_SIZE) {
+ g_autofree char *path = object_get_canonical_path(OBJECT(s));
+ qemu_log_mask(LOG_GUEST_ERROR, "%s: data left in the fifo is not"
+ " enough for transfer.\n", path);
+ break;
+ }
for (i = 0; i < CAN_FRAME_SIZE; i++) {
data[i] = fifo32_pop(fifo);
}
@@ -463,7 +469,8 @@ static void transfer_fifo(XlnxZynqMPCANState *s, Fifo32
*fifo)
* acknowledged. The XlnxZynqMPCAN core receives any message
* that it transmits.
*/
- if (fifo32_is_full(&s->rx_fifo)) {
+ if (fifo32_is_full(&s->rx_fifo) ||
+ (fifo32_num_free(&s->rx_fifo) < CAN_FRAME_SIZE)) {
ARRAY_FIELD_DP32(s->regs, INTERRUPT_STATUS_REGISTER, RXOFLW,
1);
} else {
for (i = 0; i < CAN_FRAME_SIZE; i++) {
--
2.7.4
- [PULL V2 00/10] Net patches, Jason Wang, 2023/02/16
- [PULL V2 02/10] net: Restore printing of the help text with "-nic help", Jason Wang, 2023/02/16
- [PULL V2 01/10] net: Move the code to collect available NIC models to a separate function, Jason Wang, 2023/02/16
- [PULL V2 05/10] hw/net/vmxnet3: allow VMXNET3_MAX_MTU itself as a value, Jason Wang, 2023/02/16
- [PULL V2 03/10] net: Replace "Supported NIC models" with "Available NIC models", Jason Wang, 2023/02/16
- [PULL V2 06/10] net: Increase L2TPv3 buffer to fit jumboframes, Jason Wang, 2023/02/16
- [PULL V2 04/10] hw/net/lan9118: log [read|write]b when mode_16bit is enabled rather than abort, Jason Wang, 2023/02/16
- [PULL V2 07/10] vmnet: stop recieving events when VM is stopped, Jason Wang, 2023/02/16
- [PULL V2 08/10] hw/net/can/xlnx-zynqmp-can: fix assertion failures in transfer_fifo(),
Jason Wang <=
- [PULL V2 10/10] vdpa: fix VHOST_BACKEND_F_IOTLB_ASID flag check, Jason Wang, 2023/02/16
- [PULL V2 09/10] net: stream: add a new option to automatically reconnect, Jason Wang, 2023/02/16
- Re: [PULL V2 00/10] Net patches, Philippe Mathieu-Daudé, 2023/02/16