Skip to contentSkip to conversation

staging: sm750fb: Call iounmap() to free mapped bus memory

PATCH New Fabio M. De Francesco 1 participant 1 message Apr 2, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: sm750fb: Call iounmap() to free mapped bus memory

If ioremap_wc() fails, the code jumps to the "exit" label and forgets to free the bus memory mapped into "sm750_dev->pvReg". Mapped bus memory must always be freed by calling iounmap().

Call iounmap(sm750_dev->pvReg) when the above-mentioned failures happen.

The site of the missing iounmap() has been detected by Smatch.

---
 drivers/staging/sm750fb/sm750_hw.c | 1 +
 1 file changed, 1 insertion(+)
drivers/staging/sm750fb/sm750_hw.c +1 -0
index a7c6eb07b62e..55cb00e8b0d1 100644
@@ -81,6 +81,7 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 	sm750_dev->pvMem =
 		ioremap_wc(sm750_dev->vidmem_start, sm750_dev->vidmem_size);
 	if (!sm750_dev->pvMem) {
+		iounmap(sm750_dev->pvReg);
 		pr_err("Map video memory failed\n");
 		ret = -EFAULT;
 		goto exit;
Signature · 1 line
2.34.1