Skip to content

Commit

Permalink
configfs: add missing mutex_unlock()
Browse files Browse the repository at this point in the history
d_alloc() failure in configfs_register_subsystem() would fail to unlock
the mutex taken above.  Reorganize the exit path to ensure the unlock
happens.

Reported-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
  • Loading branch information
Joel Becker authored and Mark Fasheh committed Mar 14, 2007
1 parent 03f981c commit afdf04e
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,25 +1141,22 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)

err = -ENOMEM;
dentry = d_alloc(configfs_sb->s_root, &name);
if (!dentry)
goto out_release;

d_add(dentry, NULL);
if (dentry) {
d_add(dentry, NULL);

err = configfs_attach_group(sd->s_element, &group->cg_item,
dentry);
if (!err)
dentry = NULL;
else
d_delete(dentry);
err = configfs_attach_group(sd->s_element, &group->cg_item,
dentry);
if (err) {
d_delete(dentry);
dput(dentry);
}
}

mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);

if (dentry) {
dput(dentry);
out_release:
unlink_group(group);
configfs_release_fs();
if (err) {
unlink_group(group);
configfs_release_fs();
}

return err;
Expand Down

0 comments on commit afdf04e

Please sign in to comment.