From: Zijun Hu <quic_zijuhu@quicinc.com>
Add simple error handling for buses_init() since it is easy to do.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
drivers/base/bus.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index ffea0728b8b2..e7d7a94fba4e 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1385,8 +1385,13 @@ int __init buses_init(void)
return -ENOMEM;
system_kset = kset_create_and_add("system", NULL, &devices_kset->kobj);
- if (!system_kset)
+ if (!system_kset) {
+ /* Do error handling here as devices_init() do */
+ kset_unregister(bus_kset);
+ bus_kset = NULL;
+ pr_err("%s: failed to create and add kset 'bus'\n", __func__);
return -ENOMEM;
+ }
return 0;
}
---
base-commit: 1722389b0d863056d78287a120a1d6cadb8d4f7b
change-id: 20240727-buses_init-cd9f76951ef9
Best regards,
--
Zijun Hu <quic_zijuhu@quicinc.com>