staging: sm750fb: Call iounmap() to free mapped bus memory
authorFabio M. De Francesco <fmdefrancesco@gmail.com>
Sat, 2 Apr 2022 17:56:55 +0000 (19:56 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Apr 2022 05:33:49 +0000 (07:33 +0200)
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.

Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
Link: https://lore.kernel.org/r/20220402175655.31512-1-fmdefrancesco@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/sm750fb/sm750_hw.c

index a7c6eb07b62e0ad2ba0283a100a9734d5ad172fc..55cb00e8b0d1cb3a73403c8467f68a6a6684a738 100644 (file)
@@ -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;