mailbox: imx: Avoid using val uninitialized in imx_mu_isr()
authorNathan Chancellor <nathan@kernel.org>
Mon, 21 Jun 2021 18:56:45 +0000 (11:56 -0700)
committerJassi Brar <jaswinder.singh@linaro.org>
Sat, 26 Jun 2021 17:06:18 +0000 (12:06 -0500)
Clang warns:

drivers/mailbox/imx-mailbox.c:284:2: warning: variable 'val' is used
uninitialized whenever switch default is taken
[-Wsometimes-uninitialized]
        default:
        ^~~~~~~
drivers/mailbox/imx-mailbox.c:288:7: note: uninitialized use occurs here
        if (!val)
             ^~~
drivers/mailbox/imx-mailbox.c:263:9: note: initialize the variable 'val'
to silence this warning
        u32 val, ctrl;
               ^
                = 0
1 warning generated.

Prior to commit 91c8c1fbe498 ("mailbox: imx: add xSR/xCR register
array"), val was always initialized in imx_mu_isr() but now, it is not
initialized in the default case. Return IRQ_NONE like the statement
below does and add a message that there is an unhandled type for this
switch statement so that it can be updated.

Fixes: 91c8c1fbe498 ("mailbox: imx: add xSR/xCR register array")
Link: https://github.com/ClangBuiltLinux/linux/issues/1404
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
drivers/mailbox/imx-mailbox.c

index bc51bd3..0ce75c6 100644 (file)
@@ -282,7 +282,9 @@ static irqreturn_t imx_mu_isr(int irq, void *p)
                        (ctrl & IMX_MU_xCR_GIEn(priv->dcfg->type, cp->idx));
                break;
        default:
-               break;
+               dev_warn_ratelimited(priv->dev, "Unhandled channel type %d\n",
+                                    cp->type);
+               return IRQ_NONE;
        }
 
        if (!val)