mailbox: tegra: avoid resume NULL mailboxes
authorBitan Biswas <bbiswas@nvidia.com>
Fri, 14 Jun 2019 16:31:01 +0000 (09:31 -0700)
committerJassi Brar <jaswinder.singh@linaro.org>
Thu, 11 Jul 2019 04:08:44 +0000 (23:08 -0500)
If Tegra HSP device tree does not have 'shared irqs',
mailboxes pointer is NULL. Add non-NULL HSP mailboxes
check in resume callback before tegra_hsp_mailbox_startup()
call and prevent NULL pointer exception.

Signed-off-by: Bitan Biswas <bbiswas@nvidia.com>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
drivers/mailbox/tegra-hsp.c

index 91e223e..4c5ba35 100644 (file)
@@ -782,11 +782,13 @@ static int __maybe_unused tegra_hsp_resume(struct device *dev)
                        tegra_hsp_doorbell_startup(db->channel.chan);
        }
 
-       for (i = 0; i < hsp->num_sm; i++) {
-               struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
+       if (hsp->mailboxes) {
+               for (i = 0; i < hsp->num_sm; i++) {
+                       struct tegra_hsp_mailbox *mb = &hsp->mailboxes[i];
 
-               if (mb->channel.chan->cl)
-                       tegra_hsp_mailbox_startup(mb->channel.chan);
+                       if (mb->channel.chan->cl)
+                               tegra_hsp_mailbox_startup(mb->channel.chan);
+               }
        }
 
        return 0;