lkml.org 
[lkml]   [2021]   [Nov]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.14 295/849] media: allegro: ignore interrupt if mailbox is not initialized
    Date
    From: Michael Tretter <m.tretter@pengutronix.de>

    [ Upstream commit 1ecda6393db4be44aba27a243e648dc98c9b92e3 ]

    The mailbox is initialized after the interrupt handler is installed. As
    the firmware is loaded and started even later, it should not happen that
    the interrupt occurs without the mailbox being initialized.

    As the Linux Driver Verification project (linuxtesting.org) keeps
    reporting this as an error, add a check to ignore interrupts before the
    mailbox is initialized to fix this potential null pointer dereference.

    Reported-by: Yuri Savinykh <s02190703@gse.cs.msu.ru>
    Reported-by: Nadezda Lutovinova <lutovinova@ispras.ru>
    Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
    Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/media/platform/allegro-dvt/allegro-core.c | 9 +++++++++
    1 file changed, 9 insertions(+)

    diff --git a/drivers/media/platform/allegro-dvt/allegro-core.c b/drivers/media/platform/allegro-dvt/allegro-core.c
    index 887b492e4ad1c..14a119b43bca0 100644
    --- a/drivers/media/platform/allegro-dvt/allegro-core.c
    +++ b/drivers/media/platform/allegro-dvt/allegro-core.c
    @@ -2185,6 +2185,15 @@ static irqreturn_t allegro_irq_thread(int irq, void *data)
    {
    struct allegro_dev *dev = data;

    + /*
    + * The firmware is initialized after the mailbox is setup. We further
    + * check the AL5_ITC_CPU_IRQ_STA register, if the firmware actually
    + * triggered the interrupt. Although this should not happen, make sure
    + * that we ignore interrupts, if the mailbox is not initialized.
    + */
    + if (!dev->mbox_status)
    + return IRQ_NONE;
    +
    allegro_mbox_notify(dev->mbox_status);

    return IRQ_HANDLED;
    --
    2.33.0


    \
     
     \ /
      Last update: 2021-11-15 23:33    [W:3.049 / U:0.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site