driver core: class: remove boilerplate code

Jump to err_out to avoid duplicating the code.

Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Link: https://lore.kernel.org/r/20231020160042.759439-1-mlombard@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Maurizio Lombardi 2023-10-20 18:00:42 +02:00 committed by Greg Kroah-Hartman
parent 36b2d7dd5a
commit 28f2d57d88

View File

@ -193,10 +193,8 @@ int class_register(const struct class *cls)
lockdep_register_key(key);
__mutex_init(&cp->mutex, "subsys mutex", key);
error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
if (error) {
kfree(cp);
return error;
}
if (error)
goto err_out;
cp->subsys.kobj.kset = class_kset;
cp->subsys.kobj.ktype = &class_ktype;