From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: John Snow <jsnow@redhat.com>, Stefan Weil <sw@weilnetz.de>,
"Richard W.M. Jones" <rjones@redhat.com>,
Hanna Reitz <hreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>,
qemu-block@nongnu.org
Subject: Re: [PATCH 3/7] hw/block/pflash_cfi01: Don't decrement pfl->counter below 0
Date: Mon, 5 Aug 2024 20:20:38 +0200 [thread overview]
Message-ID: <aa7d0d31-415f-4c50-a77c-1beef1da9196@linaro.org> (raw)
In-Reply-To: <20240731143617.3391947-4-peter.maydell@linaro.org>
On 31/7/24 16:36, Peter Maydell wrote:
> In pflash_write() Coverity points out that we can decrement the
> unsigned pfl->counter below zero, which makes it wrap around. In
> fact this is harmless, because if pfl->counter is 0 at this point we
> also increment pfl->wcycle to 3, and the wcycle == 3 handling doesn't
> look at counter; the only way back into code which looks at the
> counter value is via wcycle == 1, which will reinitialize the counter.
> But it's arguably a little clearer to break early in the "counter ==
> 0" if(), to avoid the decrement-below-zero.
>
> Resolves: Coverity CID 1547611
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/block/pflash_cfi01.c | 1 +
> 1 file changed, 1 insertion(+)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2024-08-05 18:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-31 14:36 [PATCH 0/7] block: Miscellaneous minor Coverity fixes Peter Maydell
2024-07-31 14:36 ` [PATCH 1/7] block/vdi.c: Avoid potential overflow when calculating size of write Peter Maydell
2024-07-31 14:59 ` Kevin Wolf
2024-07-31 15:05 ` Stefan Weil via
2024-07-31 14:36 ` [PATCH 2/7] block/gluster: Use g_autofree for string in qemu_gluster_parse_json() Peter Maydell
2024-07-31 15:04 ` Kevin Wolf
2024-07-31 20:54 ` Philippe Mathieu-Daudé
2024-07-31 14:36 ` [PATCH 3/7] hw/block/pflash_cfi01: Don't decrement pfl->counter below 0 Peter Maydell
2024-07-31 15:07 ` Kevin Wolf
2024-08-05 18:20 ` Philippe Mathieu-Daudé [this message]
2024-07-31 14:36 ` [PATCH 4/7] hw/ide/atapi: Be explicit that assigning to s->lcyl truncates Peter Maydell
2024-07-31 14:46 ` Markus Armbruster
2024-07-31 14:49 ` Peter Maydell
2024-07-31 14:57 ` Kevin Wolf
2024-07-31 14:36 ` [PATCH 5/7] hw/block/fdc-isa: Assert that isa_fdc_get_drive_max_chs() found something Peter Maydell
2024-07-31 14:50 ` Markus Armbruster
2024-07-31 14:54 ` Kevin Wolf
2024-07-31 20:56 ` Philippe Mathieu-Daudé
2024-07-31 14:36 ` [PATCH 6/7] hw/ide/pci.c: Remove dead code from bmdma_prepare_buf() Peter Maydell
2024-07-31 15:13 ` Kevin Wolf
2024-07-31 21:02 ` Philippe Mathieu-Daudé
2024-07-31 14:36 ` [PATCH 7/7] block/ssh.c: Don't double-check that characters are hex digits Peter Maydell
2024-07-31 15:21 ` Kevin Wolf
2024-07-31 15:26 ` Peter Maydell
2024-08-05 18:21 ` [PATCH 0/7] block: Miscellaneous minor Coverity fixes Philippe Mathieu-Daudé
2024-08-06 8:11 ` Philippe Mathieu-Daudé
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=aa7d0d31-415f-4c50-a77c-1beef1da9196@linaro.org \
--to=philmd@linaro.org \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rjones@redhat.com \
--cc=sw@weilnetz.de \
/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).