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.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index d2eac3ceed5f..f50e3cc2ded8 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -3,6 +3,7 @@
3 */ 3 */
4 4
5#include <linux/fs.h> 5#include <linux/fs.h>
6#include <linux/mount.h>
6#include <linux/module.h> 7#include <linux/module.h>
7#include <linux/kobject.h> 8#include <linux/kobject.h>
8#include <linux/namei.h> 9#include <linux/namei.h>
@@ -82,10 +83,19 @@ exit1:
82 */ 83 */
83int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name) 84int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char * name)
84{ 85{
85 struct dentry * dentry = kobj->dentry; 86 struct dentry *dentry = NULL;
86 int error = -EEXIST; 87 int error = -EEXIST;
87 88
88 BUG_ON(!kobj || !kobj->dentry || !name); 89 BUG_ON(!name);
90
91 if (!kobj) {
92 if (sysfs_mount && sysfs_mount->mnt_sb)
93 dentry = sysfs_mount->mnt_sb->s_root;
94 } else
95 dentry = kobj->dentry;
96
97 if (!dentry)
98 return -EFAULT;
89 99
90 mutex_lock(&dentry->d_inode->i_mutex); 100 mutex_lock(&dentry->d_inode->i_mutex);
91 if (!sysfs_dirent_exist(dentry->d_fsdata, name)) 101 if (!sysfs_dirent_exist(dentry->d_fsdata, name))