Skip to content

Commit c370baa

Browse files
qzhuo2aegl
authored andcommitted
EDAC/i10nm: Release mdev/mbase when failing to detect HBM
On systems without HBM (High Bandwidth Memory) mdev/mbase are not released/unmapped. Add the code to release mdev/mbase when failing to detect HBM. [Tony: re-word commit message] Cc: <[email protected]> Fixes: c945088 ("EDAC/i10nm: Add support for high bandwidth memory") Reported-by: kernel test robot <[email protected]> Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Qiuxu Zhuo <[email protected]> Signed-off-by: Tony Luck <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c9e6606 commit c370baa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/edac/i10nm_base.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ static int i10nm_get_hbm_munits(void)
358358

359359
mbase = ioremap(base + off, I10NM_HBM_IMC_MMIO_SIZE);
360360
if (!mbase) {
361+
pci_dev_put(d->imc[lmc].mdev);
362+
d->imc[lmc].mdev = NULL;
363+
361364
i10nm_printk(KERN_ERR, "Failed to ioremap for hbm mc 0x%llx\n",
362365
base + off);
363366
return -ENOMEM;
@@ -368,6 +371,12 @@ static int i10nm_get_hbm_munits(void)
368371

369372
mcmtr = I10NM_GET_MCMTR(&d->imc[lmc], 0);
370373
if (!I10NM_IS_HBM_IMC(mcmtr)) {
374+
iounmap(d->imc[lmc].mbase);
375+
d->imc[lmc].mbase = NULL;
376+
d->imc[lmc].hbm_mc = false;
377+
pci_dev_put(d->imc[lmc].mdev);
378+
d->imc[lmc].mdev = NULL;
379+
371380
i10nm_printk(KERN_ERR, "This isn't an hbm mc!\n");
372381
return -ENODEV;
373382
}

0 commit comments

Comments
 (0)