* [PATCH v2] drm/ingenic: Fix missing platform_driver_unregister() call in ingenic_drm_init()
@ 2022-11-04 6:45 Yuan Can
2022-11-04 11:07 ` Paul Cercueil
0 siblings, 1 reply; 2+ messages in thread
From: Yuan Can @ 2022-11-04 6:45 UTC (permalink / raw)
To: paul, airlied, daniel, sam, linux-mips, dri-devel; +Cc: yuancan, stable
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.
Fixes: fc1acf317b01 ("drm/ingenic: Add support for the IPU")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Cc: stable@vger.kernel.org
---
Changes in v2:
- Add missing Cc: stable@vger.kernel.org
drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
index ab0515d2c420..4499a04f7c13 100644
--- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
+++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
@@ -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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] drm/ingenic: Fix missing platform_driver_unregister() call in ingenic_drm_init()
2022-11-04 6:45 [PATCH v2] drm/ingenic: Fix missing platform_driver_unregister() call in ingenic_drm_init() Yuan Can
@ 2022-11-04 11:07 ` Paul Cercueil
0 siblings, 0 replies; 2+ messages in thread
From: Paul Cercueil @ 2022-11-04 11:07 UTC (permalink / raw)
To: Yuan Can; +Cc: linux-mips, stable, dri-devel, sam
Hi,
Le ven. 4 nov. 2022 à 06:45:12 +0000, Yuan Can <yuancan@huawei.com> a
écrit :
> 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.
>
> Fixes: fc1acf317b01 ("drm/ingenic: Add support for the IPU")
> Signed-off-by: Yuan Can <yuancan@huawei.com>
> Cc: stable@vger.kernel.org
Applied, thanks!
Cheers,
-Paul
> ---
> Changes in v2:
> - Add missing Cc: stable@vger.kernel.org
>
> drivers/gpu/drm/ingenic/ingenic-drm-drv.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> index ab0515d2c420..4499a04f7c13 100644
> --- a/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> +++ b/drivers/gpu/drm/ingenic/ingenic-drm-drv.c
> @@ -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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-04 11:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 6:45 [PATCH v2] drm/ingenic: Fix missing platform_driver_unregister() call in ingenic_drm_init() Yuan Can
2022-11-04 11:07 ` Paul Cercueil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).