[PATCH 1/1] PCI/MSI: add NULL check before use of msi_desc

From: Hiraku Toyooka
Date: Tue Jan 16 2018 - 04:16:26 EST


On starting kdump kernel in arm, arm64 and powerpc, chip->irq_mask() is
called for each irq_data to mask interrupts. For MSI irqs,
pci_msi_mask_irq() is called even when the irq_data doesn't have a link
to msi_desc. This results in a NULL pointer dereference.

This patch fixes the above error by avoiding NULL msi_desc use.

Signed-off-by: Hiraku Toyooka <hiraku.toyooka@xxxxxxxxxxxxxxxx>
Cc: Bjorn Helgaas <bhelgaas@xxxxxxxxxx>
Cc: Richard Zhu <hongxing.zhu@xxxxxxx>
Cc: Lucas Stach <l.stach@xxxxxxxxxxxxxx>
Cc: Jingoo Han <jingoohan1@xxxxxxxxx>
Cc: Joao Pinto <Joao.Pinto@xxxxxxxxxxxx>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@xxxxxxx>
Cc: Russell King <linux@xxxxxxxxxxxxxxx>
Cc: Will Deacon <will.deacon@xxxxxxx>
---
drivers/pci/msi.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index e066071..a6ee274 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -227,6 +227,9 @@ static void msi_set_mask_bit(struct irq_data *data, u32 flag)
{
struct msi_desc *desc = irq_data_get_msi_desc(data);

+ if (!desc)
+ return;
+
if (desc->msi_attrib.is_msix) {
msix_mask_irq(desc, flag);
readl(desc->mask_base); /* Flush write to device */
--
2.7.4