aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/symlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r--fs/sysfs/symlink.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index c72820450e7c..27df635b786a 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -48,30 +48,15 @@ static void fill_object_path(struct kobject * kobj, char * buffer, int length)
48static int sysfs_add_link(struct dentry * parent, const char * name, struct kobject * target) 48static int sysfs_add_link(struct dentry * parent, const char * name, struct kobject * target)
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;
52 struct sysfs_dirent * sd; 51 struct sysfs_dirent * sd;
53 int error;
54 52
55 error = -ENOMEM; 53 sd = sysfs_new_dirent(name, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK);
56 sl = kzalloc(sizeof(*sl), GFP_KERNEL);
57 if (!sl)
58 goto err_out;
59
60 sl->target_kobj = kobject_get(target);
61
62 sd = sysfs_new_dirent(name, sl, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK);
63 if (!sd) 54 if (!sd)
64 goto err_out; 55 return -ENOMEM;
65 sysfs_attach_dirent(sd, parent_sd, NULL);
66 56
57 sd->s_elem.symlink.target_kobj = kobject_get(target);
58 sysfs_attach_dirent(sd, parent_sd, NULL);
67 return 0; 59 return 0;
68
69 err_out:
70 if (sl) {
71 kobject_put(sl->target_kobj);
72 kfree(sl);
73 }
74 return error;
75} 60}
76 61
77/** 62/**