Re: [2/2] mtd: fix Coverity integer handling issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 2018-11-18 at 20:18:31 UTC, Miquel Raynal wrote:
> A Coverity robot reported an integer handling issue
> (OVERFLOW_BEFORE_WIDEN) in the potentially overflowing expression:
> 
>     (mtd_div_by_ws(mtd->size, mtd) - mtd_div_by_ws(offs, mtd)) *
>     mtd_oobavail(mtd, ops)
> 
> While such overflow will certainly never happen due to the numbers
> handled, it is cleaner to fix this operation anyway.
> 
> The problem is that all the maths include 32-bit quantities, while the
> result is stored in an explicit 64-bit value.
> 
> As maxooblen will just be compared with a size_t, let's change the
> type of the variable to a size_t. This will not fix anything but will
> clarify a bit the situation. Then, do an explicit cast to fix Coverity
> warning.
> 
> Signed-off-by: Miquel Raynal <miquel.raynal@xxxxxxxxxxx>

Applied to http://git.infradead.org/linux-mtd.git mtd/next, thanks.

Boris

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux