[PATCH] drm/mcde: Fix missing platform_unregister_drivers() call in mcde_drm_register()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A problem about modprobe mcde_drm failed is triggered with the following
log given:

 [ 2387.922993] Error: Driver 'mcde-dsi' is already registered, aborting...
 [ 2387.924272] failed to register platform driver mcde_dsi_driver [mcde_drm]: -16
 modprobe: ERROR: could not insert 'mcde_drm': Device or resource busy

The reason is that mcde_drm_register() returns platform_driver_register()
directly without checking its return value, if platform_driver_register()
fails, it returns without unregistering mcde_dsi_driver, resulting the
mcde_drm can never be installed later.
A simple call graph is shown as below:

 mcde_drm_register()
   platform_register_drivers() # mcde_dsi_driver are registered
   platform_driver_register()
     driver_register()
       bus_add_driver()
         priv = kzalloc(...) # OOM happened
   # return without unregister mcde_dsi_driver

Fixing this problem by checking the return value of
platform_driver_register() and do platform_unregister_drivers() if
error happened.

Fixes: 5fc537bfd000 ("drm/mcde: Add new driver for ST-Ericsson MCDE")
Signed-off-by: Yuan Can <yuancan@xxxxxxxxxx>
---
 drivers/gpu/drm/mcde/mcde_drv.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mcde/mcde_drv.c b/drivers/gpu/drm/mcde/mcde_drv.c
index 1c4482ad507d..0391a62dc1b8 100644
--- a/drivers/gpu/drm/mcde/mcde_drv.c
+++ b/drivers/gpu/drm/mcde/mcde_drv.c
@@ -494,7 +494,12 @@ static int __init mcde_drm_register(void)
 	if (ret)
 		return ret;
 
-	return platform_driver_register(&mcde_driver);
+	ret = platform_driver_register(&mcde_driver);
+	if (ret)
+		platform_unregister_drivers(component_drivers,
+					    ARRAY_SIZE(component_drivers));
+
+	return ret;
 }
 
 static void __exit mcde_drm_unregister(void)
-- 
2.17.1




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux