]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/hyperv: Fix address space leak when Hyper-V DRM device is removed
authorMichael Kelley <mhklinux@outlook.com>
Mon, 10 Feb 2025 19:34:41 +0000 (11:34 -0800)
committerWei Liu <wei.liu@kernel.org>
Sun, 9 Mar 2025 23:46:56 +0000 (23:46 +0000)
When a Hyper-V DRM device is probed, the driver allocates MMIO space for
the vram, and maps it cacheable. If the device removed, or in the error
path for device probing, the MMIO space is released but no unmap is done.
Consequently the kernel address space for the mapping is leaked.

Fix this by adding iounmap() calls in the device removal path, and in the
error path during device probing.

Fixes: f1f63cbb705d ("drm/hyperv: Fix an error handling path in hyperv_vmbus_probe()")
Fixes: a0ab5abced55 ("drm/hyperv : Removing the restruction of VRAM allocation with PCI bar size")
Signed-off-by: Michael Kelley <mhklinux@outlook.com>
Reviewed-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Tested-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Link: https://lore.kernel.org/r/20250210193441.2414-1-mhklinux@outlook.com
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Message-ID: <20250210193441.2414-1-mhklinux@outlook.com>

drivers/gpu/drm/hyperv/hyperv_drm_drv.c

index f59abfa7622ac9fe1ac5a6b0531eb4376810349a..0d49f168a919d516db906a9e49b62a5d0ca3b3cb 100644 (file)
@@ -154,6 +154,7 @@ static int hyperv_vmbus_probe(struct hv_device *hdev,
        return 0;
 
 err_free_mmio:
+       iounmap(hv->vram);
        vmbus_free_mmio(hv->mem->start, hv->fb_size);
 err_vmbus_close:
        vmbus_close(hdev->channel);
@@ -172,6 +173,7 @@ static void hyperv_vmbus_remove(struct hv_device *hdev)
        vmbus_close(hdev->channel);
        hv_set_drvdata(hdev, NULL);
 
+       iounmap(hv->vram);
        vmbus_free_mmio(hv->mem->start, hv->fb_size);
 }