Skip to content
Commit d76779dd authored by Quanquan Cao's avatar Quanquan Cao Committed by Dan Williams
Browse files

cxl/region:Fix overflow issue in alloc_hpa()



Creating a region with 16 memory devices caused a problem. The div_u64_rem
function, used for dividing an unsigned 64-bit number by a 32-bit one,
faced an issue when SZ_256M * p->interleave_ways. The result surpassed
the maximum limit of the 32-bit divisor (4G), leading to an overflow
and a remainder of 0.
note: At this point, p->interleave_ways is 16, meaning 16 * 256M = 4G

To fix this issue, I replaced the div_u64_rem function with div64_u64_rem
and adjusted the type of the remainder.

Signed-off-by: default avatarQuanquan Cao <caoqq@fujitsu.com>
Reviewed-by: default avatarDave Jiang <dave.jiang@intel.com>
Fixes: 23a22cd1

 ("cxl/region: Allocate HPA capacity to regions")
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent d72a4caf
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment