Skip to content

Commit

Permalink
driver core: bus: Add simple error handling for buses_init()
Browse files Browse the repository at this point in the history
Add simple error handling for buses_init() since it is easy to do.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Link: https://lore.kernel.org/r/20240727-buses_init-v1-1-e863295a2c0e@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
zijun-hu authored and gregkh committed Jul 31, 2024
1 parent 0314647 commit 2bdf3b8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/base/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,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;
}

0 comments on commit 2bdf3b8

Please sign in to comment.