[PATCH 1/2] mailbox: add sanity check for channel array

From: Wolfram Sang

Date: Mon Apr 13 2026 - 06:43:08 EST


Fail gracefully if there is no channel array attached to the mailbox
controller. Otherwise the later dereference will cause an OOPS which
might not be seen because mailbox controllers might instantiate very
early. Remove the comment explaining the obvious while here.

Fixes: 2b6d83e2b8b7 ("mailbox: Introduce framework for mailbox")
Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
---

On my Renesas R-Car X5H based board, the OOPS was indeed silent. I
injected the error manually.

drivers/mailbox/mailbox.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 14d9655d5424..0ed34f8f7556 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -533,8 +533,7 @@ int mbox_controller_register(struct mbox_controller *mbox)
{
int i, txdone;

- /* Sanity check */
- if (!mbox || !mbox->dev || !mbox->ops || !mbox->num_chans)
+ if (!mbox || !mbox->dev || !mbox->ops || !mbox->chans || !mbox->num_chans)
return -EINVAL;

if (mbox->txdone_irq)
--
2.51.0