summaryrefslogtreecommitdiff
path: root/drivers/base/class.c
diff options
context:
space:
mode:
authorMaurizio Lombardi <mlombard@redhat.com>2023-10-20 18:00:42 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-10-21 23:17:11 +0200
commit28f2d57d88a71353eb1f1952d1ac4a7816612087 (patch)
tree3aa056e8b5be060d3ea2c7c9928a922334f25706 /drivers/base/class.c
parent36b2d7dd5a8ac95c8c1e69bdc93c4a6e2dc28a23 (diff)
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>
Diffstat (limited to 'drivers/base/class.c')
-rw-r--r--drivers/base/class.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 05d9df90f621..7e78aee0fd6c 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -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;