diff --git a/i2c-imc-skylake.c b/i2c-imc-skylake.c index 9f533ec..b79b2ee 100644 --- a/i2c-imc-skylake.c +++ b/i2c-imc-skylake.c @@ -276,6 +276,23 @@ static void __iomem *imc_map_ecam(struct pci_dev *pdev) } acpi_put_table(&mcfg->header); + if (!map) + return NULL; + + /* + * A wrong page here would make every engine write land on some other + * function - the exact failure mode this path exists to remove. + * Word 0 is the one register whose value is known in advance; require + * it before trusting the mapping with writes. + */ + if (readl(map) != (PCU_DEVICE << 16 | PCI_VENDOR_ID_INTEL)) { + dev_warn(&pdev->dev, + "ECAM page does not identify as %04x:%04x; not using it\n", + PCI_VENDOR_ID_INTEL, PCU_DEVICE); + devm_iounmap(&pdev->dev, map); + return NULL; + } + return map; }