Casting operands to a wider type to prevent integer overflow
authorFufu Fang <fufu.fang@arm.com>
Wed, 1 Dec 2021 11:09:09 +0000 (11:09 +0000)
committerRosen Zhelev <rosen.zhelev@arm.com>
Fri, 10 Dec 2021 12:11:30 +0000 (12:11 +0000)
commitc6a38f53c23e36c73e2d166d8613c7f844fa4ff6
tree7ab08a4f9be661ba3d9627701fb49c2e7d92c02a
parentc06709c84088e39b1b1aab9183db78b07edf1b10
Casting operands to a wider type to prevent integer overflow

Previously the calculation for total_size was done in 32-bits, as the
operands were all 32-bit signed or unsigned integers. This led to
integer overflow when the extent being allocated is too large.
total_size is finally cast to size_t, as the kernel UAPI for ION uses
size_t.

Change-Id: I7a76b2c18be25fda0bf6ef70cd8a6fe717c2903c
Signed-off-by: Fufu Fang <fufu.fang@arm.com>
util/wsialloc/wsialloc_ion.c