mirror of
https://github.com/torvalds/linux.git
synced 2026-09-11 20:13:02 +02:00
dibs: Unregister dibs_class after error
In case dibs_loopback_init() fails, e.g. because of -ENOMEM, dibs_init() must unregister dibs_class. Otherwise dibs_class and /sys/class/dibs exist even though the functionality is not available. A retry to load the module fails with -EEXIST. Unregister dibs_class in the error path of dibs_init. Note that before commitad3dfa80be("dibs: change dibs_class to a const struct") class_destroy(dibs_class) is required instead of class_unregister(&dibs_class). Fixes:8047373498("dibs: Create class dibs") Signed-off-by: Alexandra Winter <wintera@linux.ibm.com> Link: https://patch.msgid.link/20260902143438.426664-1-wintera@linux.ibm.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
5d50e90add
commit
1668a31e3b
|
|
@ -251,13 +251,19 @@ static int __init dibs_init(void)
|
|||
|
||||
rc = class_register(&dibs_class);
|
||||
if (rc)
|
||||
return rc;
|
||||
goto err;
|
||||
|
||||
rc = dibs_loopback_init();
|
||||
if (rc)
|
||||
pr_err("%s fails with %d\n", __func__, rc);
|
||||
goto err_unregister;
|
||||
|
||||
return rc;
|
||||
|
||||
err_unregister:
|
||||
class_unregister(&dibs_class);
|
||||
err:
|
||||
pr_err("%s fails with %d\n", __func__, rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void __exit dibs_exit(void)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user