From: Andrew Goodbody Date: Mon, 28 Jul 2025 15:47:09 +0000 (+0100) Subject: mailbox: zynqmp: Fix off by 1 errors X-Git-Tag: v2025.10-rc3~4^2~11 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d1c4fd514c13fbda3b3016cfa9ce00b01e42bf9;p=pandora-u-boot.git mailbox: zynqmp: Fix off by 1 errors Use resource_size to correctly calculate the size to pass to devm_ioremap and avoid the off by 1 errors previously present. This issue was found by Smatch. Signed-off-by: Andrew Goodbody Link: https://lore.kernel.org/r/20250728-zynqmp-ipi-v1-1-b2bd144a9521@linaro.org Signed-off-by: Michal Simek --- diff --git a/drivers/mailbox/zynqmp-ipi.c b/drivers/mailbox/zynqmp-ipi.c index 851aa737c03..f62277385fb 100644 --- a/drivers/mailbox/zynqmp-ipi.c +++ b/drivers/mailbox/zynqmp-ipi.c @@ -188,7 +188,7 @@ static int zynqmp_ipi_dest_probe(struct udevice *dev) return -EINVAL; }; zynqmp->local_req_regs = devm_ioremap(dev, res.start, - (res.start - res.end)); + resource_size(&res)); if (!zynqmp->local_req_regs) return -EINVAL; @@ -197,7 +197,7 @@ static int zynqmp_ipi_dest_probe(struct udevice *dev) return -EINVAL; }; zynqmp->local_res_regs = devm_ioremap(dev, res.start, - (res.start - res.end)); + resource_size(&res)); if (!zynqmp->local_res_regs) return -EINVAL; @@ -206,7 +206,7 @@ static int zynqmp_ipi_dest_probe(struct udevice *dev) return -EINVAL; }; zynqmp->remote_req_regs = devm_ioremap(dev, res.start, - (res.start - res.end)); + resource_size(&res)); if (!zynqmp->remote_req_regs) return -EINVAL; @@ -215,7 +215,7 @@ static int zynqmp_ipi_dest_probe(struct udevice *dev) return -EINVAL; }; zynqmp->remote_res_regs = devm_ioremap(dev, res.start, - (res.start - res.end)); + resource_size(&res)); if (!zynqmp->remote_res_regs) return -EINVAL;