- INIT_LIST_HEAD(&cls->devices);
- INIT_LIST_HEAD(&cls->interfaces);
- kset_init(&cls->class_dirs);
- init_MUTEX(&cls->sem);
- error = kobject_set_name(&cls->subsys.kobj, "%s", cls->name);
- if (error)
+ cp = kzalloc(sizeof(*cp), GFP_KERNEL);
+ if (!cp)
+ return -ENOMEM;
+ INIT_LIST_HEAD(&cp->devices);
+ INIT_LIST_HEAD(&cp->interfaces);
+ kset_init(&cp->class_dirs);
+ init_MUTEX(&cp->sem);
+ error = kobject_set_name(&cp->subsys.kobj, "%s", cls->name);
+ if (error) {
+ kfree(cp);