]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
cxl/region: Use do_div() for 64-bit modulo operation
authorAlison Schofield <alison.schofield@intel.com>
Sat, 17 Jan 2026 04:47:30 +0000 (20:47 -0800)
committerDave Jiang <dave.jiang@intel.com>
Thu, 22 Jan 2026 23:58:14 +0000 (16:58 -0700)
commit064c098790944fa44f6aa704eb55a5c3ed65a2fa
treee7c62b931fd7d09eefe5615e57d17c2325648963
parentb51792fd9168e581e51be98e22df5f79454e22de
cxl/region: Use do_div() for 64-bit modulo operation

div64_u64_rem() was the wrong choice for doing a modulo operation
and it was used incorrectly, causing a kernel oops by passing NULL
as the remainder parameter. Replace it with the do_div() helper
that does the intended math (gran_offset = offset % gran) and is
architecture safe.

This bug appeared during testing of unaligned address translations.
The visibility to userspace would be limited to folks doing poison
injection or clear by HPA on unaligned regions.

Fixes: 78b50b598462 ("cxl/region: Translate HPA to DPA and memdev in unaligned regions")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
Link: https://patch.msgid.link/20260117044732.567831-1-alison.schofield@intel.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/region.c