From: Pavel Pisa <pisa@cmp.felk.cvut.cz>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Jason Wang <jasowang@redhat.com>,
Vikram Garhwal <fnu.vikram@xilinx.com>,
qemu-devel@nongnu.org
Subject: Re: [PATCH for-5.2 v2 4/4] hw/net/can/ctucan_core: Use stl_le_p to write to tx_buffers
Date: Tue, 10 Nov 2020 19:03:55 +0100 [thread overview]
Message-ID: <202011101903.55958.pisa@cmp.felk.cvut.cz> (raw)
In-Reply-To: <20201110170604.5897-5-peter.maydell@linaro.org>
Hello Peter,
On Tuesday 10 of November 2020 18:06:04 Peter Maydell wrote:
> 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>
> Acked-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
> ---
> hw/net/can/ctucan_core.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/net/can/ctucan_core.c b/hw/net/can/ctucan_core.c
> index a400ad13a43..0ef528eb879 100644
> --- a/hw/net/can/ctucan_core.c
> +++ b/hw/net/can/ctucan_core.c
> @@ -305,8 +305,7 @@ void ctucan_mem_write(CtuCanCoreState *s, hwaddr addr,
> uint64_t val, addr %= CTUCAN_CORE_TXBUFF_SPAN;
> 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);
> + stl_le_p(s->tx_buffer[buff_num].data + addr, val);
> }
> } else {
> switch (addr & ~3) {
I test change soon, but this seems obvious so
Acked-by: Pavel Pisa <pisa@cmp.felk.cvut.cz>
prev parent reply other threads:[~2020-11-10 18:07 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 17:06 [PATCH for-5.2 v2 0/4] hw/net/can/ctucan: fix Coverity and other issues Peter Maydell
2020-11-10 17:06 ` [PATCH for-5.2 v2 1/4] hw/net/can/ctucan: Don't allow guest to write off end of tx_buffer Peter Maydell
2020-11-10 18:01 ` Pavel Pisa
2020-11-10 18:24 ` Peter Maydell
2020-11-10 19:30 ` Pavel Pisa
2020-11-10 21:18 ` Peter Maydell
2020-11-10 22:02 ` Pavel Pisa
2020-11-10 17:06 ` [PATCH for-5.2 v2 2/4] hw/net/can/ctucan: Avoid unused value in ctucan_send_ready_buffers() Peter Maydell
2020-11-10 19:36 ` Pavel Pisa
2020-11-10 21:05 ` Peter Maydell
2020-11-10 17:06 ` [PATCH for-5.2 v2 3/4] hw/net/can/ctucan_core: Handle big-endian hosts Peter Maydell
2020-11-10 19:37 ` Pavel Pisa
2020-11-10 17:06 ` [PATCH for-5.2 v2 4/4] hw/net/can/ctucan_core: Use stl_le_p to write to tx_buffers Peter Maydell
2020-11-10 18:03 ` Pavel Pisa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202011101903.55958.pisa@cmp.felk.cvut.cz \
--to=pisa@cmp.felk.cvut.cz \
--cc=fnu.vikram@xilinx.com \
--cc=jasowang@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).