diff options
author | Tejun Heo <htejun@gmail.com> | 2007-06-13 14:45:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 19:09:03 -0400 |
commit | dfeb9fb0343363aadc3ee00a9347d120bc2a26b1 (patch) | |
tree | f9bbba921409d021da1730b8edc95614504583cd /fs/sysfs/symlink.c | |
parent | 93e3cd8270d036953120eca83610f95d3f7374c6 (diff) |
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>
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r-- | fs/sysfs/symlink.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c index 7b9c5bfde920..b463f17f6638 100644 --- a/fs/sysfs/symlink.c +++ b/fs/sysfs/symlink.c | |||
@@ -49,30 +49,33 @@ static int sysfs_add_link(struct dentry * parent, const char * name, struct kobj | |||
49 | { | 49 | { |
50 | struct sysfs_dirent * parent_sd = parent->d_fsdata; | 50 | struct sysfs_dirent * parent_sd = parent->d_fsdata; |
51 | struct sysfs_symlink * sl; | 51 | struct sysfs_symlink * sl; |
52 | int error = 0; | 52 | int error; |
53 | 53 | ||
54 | error = -ENOMEM; | 54 | error = -ENOMEM; |
55 | sl = kmalloc(sizeof(*sl), GFP_KERNEL); | 55 | sl = kzalloc(sizeof(*sl), GFP_KERNEL); |
56 | if (!sl) | 56 | if (!sl) |
57 | goto exit1; | 57 | goto err_out; |
58 | 58 | ||
59 | sl->link_name = kmalloc(strlen(name) + 1, GFP_KERNEL); | 59 | sl->link_name = kmalloc(strlen(name) + 1, GFP_KERNEL); |
60 | if (!sl->link_name) | 60 | if (!sl->link_name) |
61 | goto exit2; | 61 | goto err_out; |
62 | 62 | ||
63 | strcpy(sl->link_name, name); | 63 | strcpy(sl->link_name, name); |
64 | sl->target_kobj = kobject_get(target); | 64 | sl->target_kobj = kobject_get(target); |
65 | 65 | ||
66 | error = sysfs_make_dirent(parent_sd, NULL, sl, S_IFLNK|S_IRWXUGO, | 66 | error = sysfs_make_dirent(parent_sd, NULL, sl, S_IFLNK|S_IRWXUGO, |
67 | SYSFS_KOBJ_LINK); | 67 | SYSFS_KOBJ_LINK); |
68 | if (!error) | 68 | if (error) |
69 | return 0; | 69 | goto err_out; |
70 | 70 | ||
71 | kobject_put(target); | 71 | return 0; |
72 | kfree(sl->link_name); | 72 | |
73 | exit2: | 73 | err_out: |
74 | kfree(sl); | 74 | if (sl) { |
75 | exit1: | 75 | kobject_put(sl->target_kobj); |
76 | kfree(sl->link_name); | ||
77 | kfree(sl); | ||
78 | } | ||
76 | return error; | 79 | return error; |
77 | } | 80 | } |
78 | 81 | ||