Skip to content

Commit

Permalink
staging: speakup: fix leaks of sysfs groups
Browse files Browse the repository at this point in the history
speakup_kobj_init() and speakup_kobj_exit() didn't remove
i18n_attr_group and main_attr_group sysfs groups.

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Vasiliy Kulikov authored and Greg Kroah-Hartman committed Oct 19, 2010
1 parent 1a88a06 commit 6a56486
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions drivers/staging/speakup/kobjects.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,24 +989,34 @@ int speakup_kobj_init(void)

speakup_kobj = kobject_create_and_add("speakup", accessibility_kobj);
if (!speakup_kobj) {
kobject_put(accessibility_kobj);
return -ENOMEM;
retval = -ENOMEM;
goto err_acc;
}

/* Create the files associated with this kobject */
retval = sysfs_create_group(speakup_kobj, &main_attr_group);
if (retval)
speakup_kobj_exit();
goto err_speakup;

retval = sysfs_create_group(speakup_kobj, &i18n_attr_group);
if (retval)
speakup_kobj_exit();
goto err_group;

return 0;

err_group:
sysfs_remove_group(speakup_kobj, &main_attr_group);
err_speakup:
kobject_put(speakup_kobj);
err_acc:
kobject_put(accessibility_kobj);
return retval;
}

void speakup_kobj_exit(void)
{
sysfs_remove_group(speakup_kobj, &i18n_attr_group);
sysfs_remove_group(speakup_kobj, &main_attr_group);
kobject_put(speakup_kobj);
kobject_put(accessibility_kobj);
}

0 comments on commit 6a56486

Please sign in to comment.