mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
driver core: soc: Unregister bus on early device registration failure
soc_bus_register() registers the SoC bus before registering a deferred
early SoC device. If soc_device_register() fails in that path, the
function returns the error directly and leaves the bus registered.
Store the returned SoC device pointer explicitly so the success and
error cases are handled separately. On failure, clear soc_bus_registered
and unregister the bus before returning the error.
Fixes: 6e12db376b ("base: soc: Allow early registration of a single SoC device")
Signed-off-by: Yuho Choi <dbgh9129@gmail.com>
Link: https://patch.msgid.link/20260615180746.713540-1-dbgh9129@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Danilo Krummrich
parent
ba3dedcf3b
commit
45dfa00489
+13
-2
@@ -191,6 +191,7 @@ EXPORT_SYMBOL_GPL(soc_device_unregister);
|
||||
|
||||
static int __init soc_bus_register(void)
|
||||
{
|
||||
struct soc_device *soc_dev;
|
||||
int ret;
|
||||
|
||||
ret = bus_register(&soc_bus_type);
|
||||
@@ -198,10 +199,20 @@ static int __init soc_bus_register(void)
|
||||
return ret;
|
||||
soc_bus_registered = true;
|
||||
|
||||
if (early_soc_dev_attr)
|
||||
return PTR_ERR(soc_device_register(early_soc_dev_attr));
|
||||
if (early_soc_dev_attr) {
|
||||
soc_dev = soc_device_register(early_soc_dev_attr);
|
||||
if (IS_ERR(soc_dev)) {
|
||||
ret = PTR_ERR(soc_dev);
|
||||
goto err_unregister_bus;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_unregister_bus:
|
||||
soc_bus_registered = false;
|
||||
bus_unregister(&soc_bus_type);
|
||||
return ret;
|
||||
}
|
||||
core_initcall(soc_bus_register);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user