The pci driver must not kept registered if the module is unloaded after
vmbus_driver_register() fails. So check the return value of
vmbus_driver_register() and unregister the pci driver on failure.

Fixes: 76c56a5affeb ("drm/hyperv: Add DRM driver for hyperv synthetic video 
device")
Signed-off-by: Uwe Kleine-König (The Capable Hub) <[email protected]>
---
 drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c 
b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
index 20f35c48c0b8..2e75fb793495 100644
--- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
+++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
@@ -249,7 +249,11 @@ static int __init hv_drm_init(void)
        if (ret != 0)
                return ret;
 
-       return vmbus_driver_register(&hv_drm_hv_driver);
+       ret = vmbus_driver_register(&hv_drm_hv_driver);
+       if (ret)
+               pci_unregister_driver(&hv_drm_pci_driver);
+
+       return ret;
 }
 
 static void __exit hv_drm_exit(void)
-- 
2.55.0.11.g153666a7d9bb


Reply via email to