sysfs: flatten cleanup paths in sysfs_add_link() and create_dir()
Flatten cleanup paths in sysfs_add_link() and create_dir() to improve readability and ease further changes to these functions. This is in preparation of object reference simplification. Signed-off-by: Tejun Heo <htejun@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
93e3cd8270
commit
dfeb9fb034
@@ -49,30 +49,33 @@ static int sysfs_add_link(struct dentry * parent, const char * name, struct kobj
|
||||
{
|
||||
struct sysfs_dirent * parent_sd = parent->d_fsdata;
|
||||
struct sysfs_symlink * sl;
|
||||
int error = 0;
|
||||
int error;
|
||||
|
||||
error = -ENOMEM;
|
||||
sl = kmalloc(sizeof(*sl), GFP_KERNEL);
|
||||
sl = kzalloc(sizeof(*sl), GFP_KERNEL);
|
||||
if (!sl)
|
||||
goto exit1;
|
||||
goto err_out;
|
||||
|
||||
sl->link_name = kmalloc(strlen(name) + 1, GFP_KERNEL);
|
||||
if (!sl->link_name)
|
||||
goto exit2;
|
||||
goto err_out;
|
||||
|
||||
strcpy(sl->link_name, name);
|
||||
sl->target_kobj = kobject_get(target);
|
||||
|
||||
error = sysfs_make_dirent(parent_sd, NULL, sl, S_IFLNK|S_IRWXUGO,
|
||||
SYSFS_KOBJ_LINK);
|
||||
if (!error)
|
||||
return 0;
|
||||
if (error)
|
||||
goto err_out;
|
||||
|
||||
kobject_put(target);
|
||||
kfree(sl->link_name);
|
||||
exit2:
|
||||
kfree(sl);
|
||||
exit1:
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
if (sl) {
|
||||
kobject_put(sl->target_kobj);
|
||||
kfree(sl->link_name);
|
||||
kfree(sl);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user