[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/7] hw/block/pflash_cfi01: Don't decrement pfl->counter belo
From: |
Kevin Wolf |
Subject: |
Re: [PATCH 3/7] hw/block/pflash_cfi01: Don't decrement pfl->counter below 0 |
Date: |
Wed, 31 Jul 2024 17:07:20 +0200 |
Am 31.07.2024 um 16:36 hat Peter Maydell geschrieben:
> 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>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
- [PATCH 0/7] block: Miscellaneous minor Coverity fixes, Peter Maydell, 2024/07/31
- [PATCH 1/7] block/vdi.c: Avoid potential overflow when calculating size of write, Peter Maydell, 2024/07/31
- [PATCH 5/7] hw/block/fdc-isa: Assert that isa_fdc_get_drive_max_chs() found something, Peter Maydell, 2024/07/31
- [PATCH 3/7] hw/block/pflash_cfi01: Don't decrement pfl->counter below 0, Peter Maydell, 2024/07/31
- Re: [PATCH 3/7] hw/block/pflash_cfi01: Don't decrement pfl->counter below 0,
Kevin Wolf <=
- [PATCH 4/7] hw/ide/atapi: Be explicit that assigning to s->lcyl truncates, Peter Maydell, 2024/07/31
- [PATCH 7/7] block/ssh.c: Don't double-check that characters are hex digits, Peter Maydell, 2024/07/31
- [PATCH 2/7] block/gluster: Use g_autofree for string in qemu_gluster_parse_json(), Peter Maydell, 2024/07/31