The cleanup loop was starting at the wrong array index, causing
out-of-bounds access.
Start the loop at the correct index for zero-indexed arrays to prevent
accessing memory beyond the allocated array bounds.
Fixes: 4981b82ba2ff ("mailbox: ZynqMP IPI mailbox controller")
Signed-off-by: Harini T <harini.t@amd.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
        if (pdata->irq < MAX_SGI)
                xlnx_mbox_cleanup_sgi(pdata);
 
-       i = pdata->num_mboxes;
+       i = pdata->num_mboxes - 1;
        for (; i >= 0; i--) {
                ipi_mbox = &pdata->ipi_mboxes[i];
                if (device_is_registered(&ipi_mbox->dev))