media: platform: exynos4-is: Fix error handling in fimc_md_init()
[ Upstream commit b434422c45282a0573d8123239abc41fa72665d4 ]
A problem about modprobe s5p_fimc failed is triggered with the
following log given:
[ 272.075275] Error: Driver 'exynos4-fimc' is already registered, aborting...
modprobe: ERROR: could not insert 's5p_fimc': Device or resource busy
The reason is that fimc_md_init() returns platform_driver_register()
directly without checking its return value, if platform_driver_register()
failed, it returns without unregister fimc_driver, resulting the
s5p_fimc can never be installed later.
A simple call graph is shown as below:
fimc_md_init()
fimc_register_driver() # register fimc_driver
platform_driver_register()
platform_driver_register()
driver_register()
bus_add_driver()
dev = kzalloc(...) # OOM happened
# return without unregister fimc_driver
Fix by unregister fimc_driver when platform_driver_register() returns
error.
Fixes: d3953223b0
("[media] s5p-fimc: Add the media device driver")
Signed-off-by: Yuan Can <yuancan@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
7b02c50d39
commit
9ca9d7fd7d
@ -1231,7 +1231,7 @@ int __init fimc_register_driver(void)
|
|||||||
return platform_driver_register(&fimc_driver);
|
return platform_driver_register(&fimc_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __exit fimc_unregister_driver(void)
|
void fimc_unregister_driver(void)
|
||||||
{
|
{
|
||||||
platform_driver_unregister(&fimc_driver);
|
platform_driver_unregister(&fimc_driver);
|
||||||
}
|
}
|
||||||
|
@ -1581,7 +1581,11 @@ static int __init fimc_md_init(void)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
return platform_driver_register(&fimc_md_driver);
|
ret = platform_driver_register(&fimc_md_driver);
|
||||||
|
if (ret)
|
||||||
|
fimc_unregister_driver();
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit fimc_md_exit(void)
|
static void __exit fimc_md_exit(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user