drm/ingenic: Fix missing platform_driver_unregister() call in ingenic_drm_init()
Subsystems (4)
PATCH 1/1 drm/ingenic: Fix missing platform_driver_unregister() call in ingenic_drm_init()
A problem about modprobe ingenic-drm failed is triggered with the following log given:
[ 303.561088] Error: Driver 'ingenic-ipu' is already registered, aborting... modprobe: ERROR: could not insert 'ingenic_drm': Device or resource busy
The reason is that ingenic_drm_init() returns platform_driver_register() directly without checking its return value, if platform_driver_register() failed, it returns without unregistering ingenic_ipu_driver_ptr, resulting the ingenic-drm can never be installed later.
A simple call graph is shown as below:
ingenic_drm_init()
platform_driver_register() # ingenic_ipu_driver_ptr are registered platform_driver_register()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
# return without unregister ingenic_ipu_driver_ptr
Fixing this problem by checking the return value of platform_driver_register() and do platform_unregister_drivers() if error happened.
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/ingenic/ingenic-drm-drv.c +5 -1
@@ -1629,7 +1629,11 @@ static int ingenic_drm_init(void)return err; } -return platform_driver_register (&ingenic_drm_driver); + err =platform_driver_register (&ingenic_drm_driver); +if (IS_ENABLED (CONFIG_DRM_INGENIC_IPU ) && err) +platform_driver_unregister (ingenic_ipu_driver_ptr); + +return err; }module_init (ingenic_drm_init);
Signature · 1 line
2.17.1
Paul Cercueil
maintainerHi Yuan,
Quoted 20 lines · Yuan Can
A problem about modprobe ingenic-drm failed is triggered with the following log given:
[ 303.561088] Error: Driver 'ingenic-ipu' is already registered,aborting...
modprobe: ERROR: could not insert 'ingenic_drm': Device or resource
busyThe reason is that
ingenic_drm_init()returnsplatform_driver_register()directly without checking its return value, ifplatform_driver_register()failed, it returns without unregisteringingenic_ipu_driver_ptr, resulting the ingenic-drm can never be installed later.
A simple call graph is shown as below:
ingenic_drm_init()
platform_driver_register()#ingenic_ipu_driver_ptrare registeredplatform_driver_register()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened
Quoted 8 lines
# return without unregister ingenic_ipu_driver_ptrFixing this problem by checking the return value of
platform_driver_register()and doplatform_unregister_drivers()if error happened.Fixes fc1acf317b01 ("drm/ingenic: Add support for the IPU")Signed-off-by Yuan Can <[email protected]>
Missing a Cc: to linux-stable, no?
Cheers,
-Paul
Quoted 24 lines
--- drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/gpu/drm/ingenic/ingenic-drm-drv.c +5
-2@@ -1629,7 +1629,11 @@ static int ingenic_drm_init(void)return err; } -return platform_driver_register (&ingenic_drm_driver); + err =platform_driver_register (&ingenic_drm_driver); +if (IS_ENABLED (CONFIG_DRM_INGENIC_IPU ) && err) +platform_driver_unregister (ingenic_ipu_driver_ptr); + +return err; }module_init (ingenic_drm_init); --2.17.1
Quoted 27 lines · Paul Cercueil
Hi Yuan,
Quoted 24 lines · Yuan Can
A problem about modprobe ingenic-drm failed is triggered with the following log given:
[ 303.561088] Error: Driver 'ingenic-ipu' is already registered, aborting...
modprobe: ERROR: could not insert 'ingenic_drm': Device or resource busyThe reason is that
ingenic_drm_init()returnsplatform_driver_register()directly without checking its return value, ifplatform_driver_register()failed, it returns without unregisteringingenic_ipu_driver_ptr, resulting the ingenic-drm can never be installed later.
A simple call graph is shown as below:ingenic_drm_init()
platform_driver_register()#ingenic_ipu_driver_ptrare registeredplatform_driver_register()
driver_register()
bus_add_driver()
priv = kzalloc(...) # OOM happened# return without unregister ingenic_ipu_driver_ptrFixing this problem by checking the return value of
platform_driver_register()and doplatform_unregister_drivers()if error happened.
Quoted 7 lines
Quoted 2 lines
Fixes fc1acf317b01 ("drm/ingenic: Add support for the IPU")Signed-off-by Yuan Can <[email protected]>Missing a Cc: to linux-stable, no?
Cheers,
-Paul
Ok, I will cc to linux-stable in the v2 patch, thanks for the review.
Signature · 2 lines
Best regards, Yuan Can