aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-18 21:28:08 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-18 21:28:08 -0400
commit29e7ee378e2327c808ede66dec4d4d964f4d375f (patch)
tree4f904bfc485acd2ba5f7abdf43f57eeb8ce1dbdb /fs
parentfc15bc817eecd5c13581adab2a182c07edededa0 (diff)
parent967e35dcc9ac194b4a6fad69a5a51f93d69bb0d1 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-2.6: sysfs: cosmetic clean up on node creation failure paths sysfs: kill an extra put in sysfs_create_link() failure path Driver core: check return code of sysfs_create_link() HOWTO: Add the knwon_regression URI to the documentation dev_vdbg() documentation dev_vdbg(), available with -DVERBOSE_DEBUG sysfs: make sysfs_init_inode() static sysfs: fix sysfs root inode nlink accounting Documentation fix devres.txt: lib/iomap.c -> lib/devres.c sysfs: avoid kmem_cache_free(NULL) PM: remove deprecated dpm_runtime_* routines PM: Remove deprecated sysfs files Driver core: accept all valid action-strings in uevent-trigger debugfs: remove rmdir() non-empty complaint
Diffstat (limited to 'fs')
-rw-r--r--fs/debugfs/inode.c5
-rw-r--r--fs/sysfs/dir.c25
-rw-r--r--fs/sysfs/file.c9
-rw-r--r--fs/sysfs/inode.c2
-rw-r--r--fs/sysfs/mount.c10
-rw-r--r--fs/sysfs/symlink.c12
-rw-r--r--fs/sysfs/sysfs.h1
7 files changed, 33 insertions, 31 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 1d533a2ec3a6..11be8a325e26 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -345,11 +345,6 @@ void debugfs_remove(struct dentry *dentry)
345 switch (dentry->d_inode->i_mode & S_IFMT) { 345 switch (dentry->d_inode->i_mode & S_IFMT) {
346 case S_IFDIR: 346 case S_IFDIR:
347 ret = simple_rmdir(parent->d_inode, dentry); 347 ret = simple_rmdir(parent->d_inode, dentry);
348 if (ret)
349 printk(KERN_ERR
350 "DebugFS rmdir on %s failed : "
351 "directory not empty.\n",
352 dentry->d_name.name);
353 break; 348 break;
354 case S_IFLNK: 349 case S_IFLNK:
355 kfree(dentry->d_inode->i_private); 350 kfree(dentry->d_inode->i_private);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index aee966c44aac..048e6054c2fd 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -361,20 +361,20 @@ static struct dentry_operations sysfs_dentry_ops = {
361struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type) 361struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
362{ 362{
363 char *dup_name = NULL; 363 char *dup_name = NULL;
364 struct sysfs_dirent *sd = NULL; 364 struct sysfs_dirent *sd;
365 365
366 if (type & SYSFS_COPY_NAME) { 366 if (type & SYSFS_COPY_NAME) {
367 name = dup_name = kstrdup(name, GFP_KERNEL); 367 name = dup_name = kstrdup(name, GFP_KERNEL);
368 if (!name) 368 if (!name)
369 goto err_out; 369 return NULL;
370 } 370 }
371 371
372 sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL); 372 sd = kmem_cache_zalloc(sysfs_dir_cachep, GFP_KERNEL);
373 if (!sd) 373 if (!sd)
374 goto err_out; 374 goto err_out1;
375 375
376 if (sysfs_alloc_ino(&sd->s_ino)) 376 if (sysfs_alloc_ino(&sd->s_ino))
377 goto err_out; 377 goto err_out2;
378 378
379 atomic_set(&sd->s_count, 1); 379 atomic_set(&sd->s_count, 1);
380 atomic_set(&sd->s_active, 0); 380 atomic_set(&sd->s_active, 0);
@@ -386,9 +386,10 @@ struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type)
386 386
387 return sd; 387 return sd;
388 388
389 err_out: 389 err_out2:
390 kfree(dup_name);
391 kmem_cache_free(sysfs_dir_cachep, sd); 390 kmem_cache_free(sysfs_dir_cachep, sd);
391 err_out1:
392 kfree(dup_name);
392 return NULL; 393 return NULL;
393} 394}
394 395
@@ -698,17 +699,19 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
698 699
699 /* link in */ 700 /* link in */
700 sysfs_addrm_start(&acxt, parent_sd); 701 sysfs_addrm_start(&acxt, parent_sd);
702
701 if (!sysfs_find_dirent(parent_sd, name)) { 703 if (!sysfs_find_dirent(parent_sd, name)) {
702 sysfs_add_one(&acxt, sd); 704 sysfs_add_one(&acxt, sd);
703 sysfs_link_sibling(sd); 705 sysfs_link_sibling(sd);
704 } 706 }
705 if (sysfs_addrm_finish(&acxt)) { 707
706 *p_sd = sd; 708 if (!sysfs_addrm_finish(&acxt)) {
707 return 0; 709 sysfs_put(sd);
710 return -EEXIST;
708 } 711 }
709 712
710 sysfs_put(sd); 713 *p_sd = sd;
711 return -EEXIST; 714 return 0;
712} 715}
713 716
714int sysfs_create_subdir(struct kobject *kobj, const char *name, 717int sysfs_create_subdir(struct kobject *kobj, const char *name,
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index cc497994b2a8..3e1cc062a740 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -410,11 +410,12 @@ int sysfs_add_file(struct sysfs_dirent *dir_sd, const struct attribute *attr,
410 sysfs_link_sibling(sd); 410 sysfs_link_sibling(sd);
411 } 411 }
412 412
413 if (sysfs_addrm_finish(&acxt)) 413 if (!sysfs_addrm_finish(&acxt)) {
414 return 0; 414 sysfs_put(sd);
415 return -EEXIST;
416 }
415 417
416 sysfs_put(sd); 418 return 0;
417 return -EEXIST;
418} 419}
419 420
420 421
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 3756e152285a..10d1b52899f1 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -133,7 +133,7 @@ static inline void set_inode_attr(struct inode * inode, struct iattr * iattr)
133 */ 133 */
134static struct lock_class_key sysfs_inode_imutex_key; 134static struct lock_class_key sysfs_inode_imutex_key;
135 135
136void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode) 136static void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode)
137{ 137{
138 inode->i_blocks = 0; 138 inode->i_blocks = 0;
139 inode->i_mapping->a_ops = &sysfs_aops; 139 inode->i_mapping->a_ops = &sysfs_aops;
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 402cc356203c..60714d075c2f 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -43,19 +43,19 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
43 sb->s_time_gran = 1; 43 sb->s_time_gran = 1;
44 sysfs_sb = sb; 44 sysfs_sb = sb;
45 45
46 inode = new_inode(sysfs_sb); 46 /* get root inode, initialize and unlock it */
47 inode = sysfs_get_inode(&sysfs_root);
47 if (!inode) { 48 if (!inode) {
48 pr_debug("sysfs: could not get root inode\n"); 49 pr_debug("sysfs: could not get root inode\n");
49 return -ENOMEM; 50 return -ENOMEM;
50 } 51 }
51 52
52 sysfs_init_inode(&sysfs_root, inode);
53
54 inode->i_op = &sysfs_dir_inode_operations; 53 inode->i_op = &sysfs_dir_inode_operations;
55 inode->i_fop = &sysfs_dir_operations; 54 inode->i_fop = &sysfs_dir_operations;
56 /* directory inodes start off with i_nlink == 2 (for "." entry) */ 55 inc_nlink(inode); /* directory, account for "." */
57 inc_nlink(inode); 56 unlock_new_inode(inode);
58 57
58 /* instantiate and link root dentry */
59 root = d_alloc_root(inode); 59 root = d_alloc_root(inode);
60 if (!root) { 60 if (!root) {
61 pr_debug("%s: could not get root dentry!\n",__FUNCTION__); 61 pr_debug("%s: could not get root dentry!\n",__FUNCTION__);
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 2f86e0422290..4ce687f0b5d0 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -86,7 +86,9 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
86 sd = sysfs_new_dirent(name, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK); 86 sd = sysfs_new_dirent(name, S_IFLNK|S_IRWXUGO, SYSFS_KOBJ_LINK);
87 if (!sd) 87 if (!sd)
88 goto out_put; 88 goto out_put;
89
89 sd->s_elem.symlink.target_sd = target_sd; 90 sd->s_elem.symlink.target_sd = target_sd;
91 target_sd = NULL; /* reference is now owned by the symlink */
90 92
91 sysfs_addrm_start(&acxt, parent_sd); 93 sysfs_addrm_start(&acxt, parent_sd);
92 94
@@ -95,11 +97,13 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
95 sysfs_link_sibling(sd); 97 sysfs_link_sibling(sd);
96 } 98 }
97 99
98 if (sysfs_addrm_finish(&acxt)) 100 if (!sysfs_addrm_finish(&acxt)) {
99 return 0; 101 error = -EEXIST;
102 goto out_put;
103 }
104
105 return 0;
100 106
101 error = -EEXIST;
102 /* fall through */
103 out_put: 107 out_put:
104 sysfs_put(target_sd); 108 sysfs_put(target_sd);
105 sysfs_put(sd); 109 sysfs_put(sd);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 6a37f2386a8d..6b8c8d76d308 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -71,7 +71,6 @@ extern void sysfs_remove_one(struct sysfs_addrm_cxt *acxt,
71extern int sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt); 71extern int sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
72 72
73extern void sysfs_delete_inode(struct inode *inode); 73extern void sysfs_delete_inode(struct inode *inode);
74extern void sysfs_init_inode(struct sysfs_dirent *sd, struct inode *inode);
75extern struct inode * sysfs_get_inode(struct sysfs_dirent *sd); 74extern struct inode * sysfs_get_inode(struct sysfs_dirent *sd);
76extern void sysfs_instantiate(struct dentry *dentry, struct inode *inode); 75extern void sysfs_instantiate(struct dentry *dentry, struct inode *inode);
77 76