[PATCH] nftl_format: prevent unsigned underflow in INFTL virtual unit calculation
David Oberhollenzer
david.oberhollenzer at sigma-star.at
Sun Apr 12 23:24:34 PDT 2026
Hi,
On 1/27/26 1:31 PM, Anton Moryakov wrote:
> @@ -371,6 +371,8 @@ int main(int argc, char **argv)
> maxzones = meminfo.size / meminfo.erasesize;
> pezstart = startofs / meminfo.erasesize + 1;
> pezend = startofs / meminfo.erasesize + ezones - 1;
> + if (ezones < 2)
> + exit(EXIT_FAILURE);
> numvunits = (ezones - 2) * PERCENTUSED / 100;
> for (ezone = pezstart; ezone < maxzones; ezone++) {
> if (BadUnitTable[ezone] != ZONE_GOOD) {
I think at the very least we should produce some sort of error message
if this is triggered. Maybe a simple `assert(ezones >= 2)` should be
preferred here?
Greetings,
David
More information about the linux-mtd
mailing list