mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-11 00:04:33 +08:00
drm/hyperv: Fix device removal on Gen1 VMs
[ Upstream commite048834c20
] The Hyper-V DRM driver tries to free MMIO region on removing the device regardless of VM type, while Gen1 VMs don't use MMIO and hence causing the kernel to crash on a NULL pointer dereference. Fix this by making deallocating MMIO only on Gen2 machines and implement removal for Gen1 Fixes:76c56a5aff
("drm/hyperv: Add DRM driver for hyperv synthetic video device") Signed-off-by: Mohammed Gamal <mgamal@redhat.com> Reviewed-by: Deepak Rawat <drawat.floss@gmail.com> Signed-off-by: Deepak Rawat <drawat.floss@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20211119112900.300537-1-mgamal@redhat.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
63a68f3771
commit
85851d9ff7
@ -225,12 +225,29 @@ static int hyperv_vmbus_remove(struct hv_device *hdev)
|
||||
{
|
||||
struct drm_device *dev = hv_get_drvdata(hdev);
|
||||
struct hyperv_drm_device *hv = to_hv(dev);
|
||||
struct pci_dev *pdev;
|
||||
|
||||
drm_dev_unplug(dev);
|
||||
drm_atomic_helper_shutdown(dev);
|
||||
vmbus_close(hdev->channel);
|
||||
hv_set_drvdata(hdev, NULL);
|
||||
vmbus_free_mmio(hv->mem->start, hv->fb_size);
|
||||
|
||||
/*
|
||||
* Free allocated MMIO memory only on Gen2 VMs.
|
||||
* On Gen1 VMs, release the PCI device
|
||||
*/
|
||||
if (efi_enabled(EFI_BOOT)) {
|
||||
vmbus_free_mmio(hv->mem->start, hv->fb_size);
|
||||
} else {
|
||||
pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
|
||||
PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
|
||||
if (!pdev) {
|
||||
drm_err(dev, "Unable to find PCI Hyper-V video\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
pci_release_region(pdev, 0);
|
||||
pci_dev_put(pdev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user