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

drm/hyperv: Fix address space leak when Hyper-V DRM device is removed

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>

authored by

Michael Kelley and committed by
Wei Liu
aed70935 7241c886

+2
+2
drivers/gpu/drm/hyperv/hyperv_drm_drv.c
··· 154 154 return 0; 155 155 156 156 err_free_mmio: 157 + iounmap(hv->vram); 157 158 vmbus_free_mmio(hv->mem->start, hv->fb_size); 158 159 err_vmbus_close: 159 160 vmbus_close(hdev->channel); ··· 173 172 vmbus_close(hdev->channel); 174 173 hv_set_drvdata(hdev, NULL); 175 174 175 + iounmap(hv->vram); 176 176 vmbus_free_mmio(hv->mem->start, hv->fb_size); 177 177 } 178 178