On 7/28/25 17:47, Andrew Goodbody wrote:
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 <andrew.goodb...@linaro.org>
---
  drivers/mailbox/zynqmp-ipi.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)

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;
---
base-commit: 4c3b5fcd810081bd7f3c51859fe1b5f0c159803c
change-id: 20250728-zynqmp-ipi-0b1791238085

Best regards,

Applied.
M
--
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP/Versal ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal/Versal NET SoCs
TF-A maintainer - Xilinx ZynqMP/Versal/Versal NET SoCs

Reply via email to