diff options
Diffstat (limited to 'fs/sysfs/inode.c')
-rw-r--r-- | fs/sysfs/inode.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index 689f7bcfaf30..4c29ac41ac3e 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -54,11 +54,10 @@ int sysfs_setattr(struct dentry * dentry, struct iattr * iattr) | |||
54 | 54 | ||
55 | if (!sd_iattr) { | 55 | if (!sd_iattr) { |
56 | /* setting attributes for the first time, allocate now */ | 56 | /* setting attributes for the first time, allocate now */ |
57 | sd_iattr = kmalloc(sizeof(struct iattr), GFP_KERNEL); | 57 | sd_iattr = kzalloc(sizeof(struct iattr), GFP_KERNEL); |
58 | if (!sd_iattr) | 58 | if (!sd_iattr) |
59 | return -ENOMEM; | 59 | return -ENOMEM; |
60 | /* assign default attributes */ | 60 | /* assign default attributes */ |
61 | memset(sd_iattr, 0, sizeof(struct iattr)); | ||
62 | sd_iattr->ia_mode = sd->s_mode; | 61 | sd_iattr->ia_mode = sd->s_mode; |
63 | sd_iattr->ia_uid = 0; | 62 | sd_iattr->ia_uid = 0; |
64 | sd_iattr->ia_gid = 0; | 63 | sd_iattr->ia_gid = 0; |
@@ -227,12 +226,16 @@ void sysfs_drop_dentry(struct sysfs_dirent * sd, struct dentry * parent) | |||
227 | void sysfs_hash_and_remove(struct dentry * dir, const char * name) | 226 | void sysfs_hash_and_remove(struct dentry * dir, const char * name) |
228 | { | 227 | { |
229 | struct sysfs_dirent * sd; | 228 | struct sysfs_dirent * sd; |
230 | struct sysfs_dirent * parent_sd = dir->d_fsdata; | 229 | struct sysfs_dirent * parent_sd; |
230 | |||
231 | if (!dir) | ||
232 | return; | ||
231 | 233 | ||
232 | if (dir->d_inode == NULL) | 234 | if (dir->d_inode == NULL) |
233 | /* no inode means this hasn't been made visible yet */ | 235 | /* no inode means this hasn't been made visible yet */ |
234 | return; | 236 | return; |
235 | 237 | ||
238 | parent_sd = dir->d_fsdata; | ||
236 | mutex_lock(&dir->d_inode->i_mutex); | 239 | mutex_lock(&dir->d_inode->i_mutex); |
237 | list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { | 240 | list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { |
238 | if (!sd->s_element) | 241 | if (!sd->s_element) |