Skip to content

Commit

Permalink
media: allegro: ignore interrupt if mailbox is not initialized
Browse files Browse the repository at this point in the history
[ Upstream commit 1ecda63 ]

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>
  • Loading branch information
tretter authored and gregkh committed Nov 18, 2021
1 parent a3d08aa commit 451be8b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/media/platform/allegro-dvt/allegro-core.c
Expand Up @@ -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;
Expand Down

0 comments on commit 451be8b

Please sign in to comment.