Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: <stable@vger.kernel.org>
Fixes: c945088384d0 ("EDAC/i10nm: Add support for high bandwidth memory")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Link: https://lore.kernel.org/r/20211224091126.1246-1-qiuxu.zhuo@intel.com

authored by

Qiuxu Zhuo and committed by
Tony Luck
c370baa3 c9e6606c

+9
+9
drivers/edac/i10nm_base.c
··· 358 358 359 359 mbase = ioremap(base + off, I10NM_HBM_IMC_MMIO_SIZE); 360 360 if (!mbase) { 361 + pci_dev_put(d->imc[lmc].mdev); 362 + d->imc[lmc].mdev = NULL; 363 + 361 364 i10nm_printk(KERN_ERR, "Failed to ioremap for hbm mc 0x%llx\n", 362 365 base + off); 363 366 return -ENOMEM; ··· 371 368 372 369 mcmtr = I10NM_GET_MCMTR(&d->imc[lmc], 0); 373 370 if (!I10NM_IS_HBM_IMC(mcmtr)) { 371 + iounmap(d->imc[lmc].mbase); 372 + d->imc[lmc].mbase = NULL; 373 + d->imc[lmc].hbm_mc = false; 374 + pci_dev_put(d->imc[lmc].mdev); 375 + d->imc[lmc].mdev = NULL; 376 + 374 377 i10nm_printk(KERN_ERR, "This isn't an hbm mc!\n"); 375 378 return -ENODEV; 376 379 }