[PATCH RFC v2 02/10] arm_mpam: Fix MSC MMIO window size off-by-one with resource_size()
From: Yin Li
Date: Mon Sep 14 2026 - 05:55:17 EST
struct resource uses an inclusive end address, so the window size is
end - start + 1. do_mpam_msc_drv_probe() computed it as end - start,
which is one byte too small.
mapped_hwpage_sz is used by the register access bounds checks, which
have the form "offset + width > mapped_hwpage_sz". With the size one
byte too small, an access to the last register in the window is
incorrectly flagged as out of bounds: for a 0x1000 window, a 4-byte
access at offset 0xFFC (bytes 0xFFC..0xFFF, legal) computes
0xFFC + 4 = 0x1000 > 0xFFF and falsely warns.
Use resource_size() so the size is correct. The ">" bounds checks are
correct as-is once the size is accurate and are left unchanged.
Fixes: f04046f2577a ("arm_mpam: Add probe/remove for mpam msc driver and kbuild boiler plate")
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Closes: https://lore.kernel.org/oe-kbuild-all/202609030809.ObirDhR3-lkp@xxxxxxxxx/
Signed-off-by: Yin Li <yin.li@xxxxxxxxxxxxxxxx>
Reviewed-by: Andre Przywara <andre.przywara@xxxxxxx>
Reviewed-by: Ben Horgan <ben.horgan@xxxxxxx>
---
drivers/resctrl/mpam_devices.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/resctrl/mpam_devices.c b/drivers/resctrl/mpam_devices.c
index 6da217abf689..c68135ee0ffc 100644
--- a/drivers/resctrl/mpam_devices.c
+++ b/drivers/resctrl/mpam_devices.c
@@ -2095,7 +2095,7 @@ static struct mpam_msc *do_mpam_msc_drv_probe(struct platform_device *pdev)
dev_err_once(dev, "Failed to map MSC base address\n");
return ERR_CAST(io);
}
- msc->mapped_hwpage_sz = msc_res->end - msc_res->start;
+ msc->mapped_hwpage_sz = resource_size(msc_res);
msc->mapped_hwpage = io;
} else {
return ERR_PTR(-EINVAL);
--
2.34.1