diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2020-11-10 22:52:50 +0100 |
---|---|---|
committer | Jason Wang <jasowang@redhat.com> | 2020-11-11 20:34:36 +0800 |
commit | 71182187ddae5d5b17bd48464f719798321484ed (patch) | |
tree | 1f14c3a4fdbfcbb84a670d6bab9031aa2144f9d3 /hw/net | |
parent | 676ea985c0d13c9d39b9ead4c60005abb9ea4218 (diff) | |
download | qemu-71182187ddae5d5b17bd48464f719798321484ed.zip qemu-71182187ddae5d5b17bd48464f719798321484ed.tar.gz qemu-71182187ddae5d5b17bd48464f719798321484ed.tar.bz2 |
hw/net/can/ctucan_core: Use stl_le_p to write to tx_buffers
Instead of casting an address within a uint8_t array to a
uint32_t*, use stl_le_p(). This handles possibly misaligned
addresses which would otherwise crash on some hosts.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Tested-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Diffstat (limited to 'hw/net')
-rw-r--r-- | hw/net/can/ctucan_core.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/hw/net/can/ctucan_core.c b/hw/net/can/ctucan_core.c index f49c762..d171c37 100644 --- a/hw/net/can/ctucan_core.c +++ b/hw/net/can/ctucan_core.c @@ -303,11 +303,9 @@ void ctucan_mem_write(CtuCanCoreState *s, hwaddr addr, uint64_t val, addr -= CTU_CAN_FD_TXTB1_DATA_1; buff_num = addr / CTUCAN_CORE_TXBUFF_SPAN; addr %= CTUCAN_CORE_TXBUFF_SPAN; - addr &= ~3; if ((buff_num < CTUCAN_CORE_TXBUF_NUM) && - (addr < sizeof(s->tx_buffer[buff_num].data))) { - uint32_t *bufp = (uint32_t *)(s->tx_buffer[buff_num].data + addr); - *bufp = cpu_to_le32(val); + ((addr + size) <= sizeof(s->tx_buffer[buff_num].data))) { + stn_le_p(s->tx_buffer[buff_num].data + addr, size, val); } } else { switch (addr & ~3) { |