kobject: fix kset sample error path

Previously, example_init() leaked a kset if any of the object creations
failed.  This fixes the leak by calling kset_unregister() in the error
path.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Bjorn Helgaas 2013-10-08 14:20:24 -06:00 committed by Greg Kroah-Hartman
parent bfc5c17337
commit e756bc5670

View File

@ -262,6 +262,7 @@ static int __init example_init(void)
bar_error:
destroy_foo_obj(foo_obj);
foo_error:
kset_unregister(example_kset);
return -EINVAL;
}