]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mailbox: add sanity check for channel array
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Mon, 13 Apr 2026 10:42:38 +0000 (12:42 +0200)
committerJassi Brar <jassisinghbrar@gmail.com>
Sat, 18 Apr 2026 18:07:30 +0000 (13:07 -0500)
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@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
drivers/mailbox/mailbox.c

index 30eafdf3a91ec37377508ff70270352bd238a086..bbc9fd75a95f7c052485537a197c3778315e61ea 100644 (file)
@@ -526,8 +526,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)