qemu-devel
[Top][All Lists]
Advanced

[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: Philippe Mathieu-Daudé
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
User-agent: Mozilla Thunderbird

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>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]