From: Alistair Francis <alistair23@gmail.com>
To: Eden Mikitas <e.mikitas@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
QEMU Trivial <qemu-trivial@nongnu.org>,
Alistair Francis <alistair@alistair23.me>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>,
Jean-Christophe Dubois <jcd@tribudubois.net>,
qemu-arm <qemu-arm@nongnu.org>,
Peter Chubb <peter.chubb@nicta.com.au>
Subject: Re: [PATCH 1/2] hw/ssi/imx_spi: changed while statement to prevent underflow
Date: Fri, 22 May 2020 08:34:53 -0700 [thread overview]
Message-ID: <CAKmqyKOrNwjsLSAOjcj2jmcZftqAi6W-8whOwQ6nwnxC8wf-cA@mail.gmail.com> (raw)
In-Reply-To: <20200522115036.31516-2-e.mikitas@gmail.com>
On Fri, May 22, 2020 at 4:51 AM Eden Mikitas <e.mikitas@gmail.com> wrote:
>
> The while statement in question only checked if tx_burst is not 0.
> tx_burst is a signed int, which is assigned the value put by the
> guest driver in ECSPI_CONREG. The burst length can be anywhere
> between 1 and 4096, and since tx_burst is always decremented by 8
> it could possibly underflow, causing an infinite loop.
>
> Signed-off-by: Eden Mikitas <e.mikitas@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/ssi/imx_spi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/ssi/imx_spi.c b/hw/ssi/imx_spi.c
> index 2dd9a631e1..6fef5c7958 100644
> --- a/hw/ssi/imx_spi.c
> +++ b/hw/ssi/imx_spi.c
> @@ -182,7 +182,7 @@ static void imx_spi_flush_txfifo(IMXSPIState *s)
>
> rx = 0;
>
> - while (tx_burst) {
> + while (tx_burst > 0) {
> uint8_t byte = tx & 0xff;
>
> DPRINTF("writing 0x%02x\n", (uint32_t)byte);
> --
> 2.17.1
>
>
next prev parent reply other threads:[~2020-05-22 15:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-20 14:32 [PATCH] ssi/imx_spi: Removed unnecessary cast and fixed condition in while statement Eden Mikitas
2020-05-21 16:41 ` Peter Maydell
2020-05-21 18:49 ` Eden Mikitas
2020-05-21 18:56 ` Peter Maydell
2020-05-22 11:50 ` [PATCH 0/2] hw/ssi/imx_spi: 2 Fixes to flush txfifo function in imx_spi Eden Mikitas
2020-05-22 11:50 ` [PATCH 1/2] hw/ssi/imx_spi: changed while statement to prevent underflow Eden Mikitas
2020-05-22 15:34 ` Alistair Francis [this message]
2020-05-22 11:50 ` [PATCH 2/2] hw/ssi/imx_spi: Removed unnecessary cast of rx data received from slave Eden Mikitas
2020-05-22 15:36 ` Alistair Francis
2020-05-29 13:03 ` [PATCH 0/2] hw/ssi/imx_spi: 2 Fixes to flush txfifo function in imx_spi Peter Maydell
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=CAKmqyKOrNwjsLSAOjcj2jmcZftqAi6W-8whOwQ6nwnxC8wf-cA@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=alistair@alistair23.me \
--cc=e.mikitas@gmail.com \
--cc=jcd@tribudubois.net \
--cc=peter.chubb@nicta.com.au \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@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).