[PATCH] mtd: partitions: redboot: Added conversion of operands to a larger type

Andy Shevchenko andriy.shevchenko at intel.com
Mon Mar 25 03:30:05 PDT 2024


On Fri, Mar 15, 2024 at 12:37:58PM +0300, Denis Arefev wrote:
> The value of an arithmetic expression directory * master->erasesize is
> subject to overflow due to a failure to cast operands to a larger data
> type before perfroming arithmetic

...

> -		offset = directory * master->erasesize;
> +		offset = (unsigned long) directory * master->erasesize;

Usage of explicit casting can be avoided by using size_mul() from overflow.h.
Usually explicit castings are prone to subtle errors.

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-mtd mailing list