diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/sysfs/dir.c | 12 | ||||
-rw-r--r-- | fs/sysfs/inode.c | 2 |
2 files changed, 5 insertions, 9 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index b2b83067ccc8..a63eb4ba7867 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c | |||
@@ -383,12 +383,6 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd) | |||
383 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name)) | 383 | if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name)) |
384 | return -EEXIST; | 384 | return -EEXIST; |
385 | 385 | ||
386 | if (sysfs_ns_type(acxt->parent_sd) && !sd->s_ns) { | ||
387 | WARN(1, KERN_WARNING "sysfs: ns required in '%s' for '%s'\n", | ||
388 | acxt->parent_sd->s_name, sd->s_name); | ||
389 | return -EINVAL; | ||
390 | } | ||
391 | |||
392 | sd->s_parent = sysfs_get(acxt->parent_sd); | 386 | sd->s_parent = sysfs_get(acxt->parent_sd); |
393 | 387 | ||
394 | sysfs_link_sibling(sd); | 388 | sysfs_link_sibling(sd); |
@@ -545,7 +539,7 @@ struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd, | |||
545 | struct sysfs_dirent *sd; | 539 | struct sysfs_dirent *sd; |
546 | 540 | ||
547 | for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) { | 541 | for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) { |
548 | if (sd->s_ns != ns) | 542 | if (ns && sd->s_ns && (sd->s_ns != ns)) |
549 | continue; | 543 | continue; |
550 | if (!strcmp(sd->s_name, name)) | 544 | if (!strcmp(sd->s_name, name)) |
551 | return sd; | 545 | return sd; |
@@ -879,7 +873,7 @@ static struct sysfs_dirent *sysfs_dir_pos(const void *ns, | |||
879 | while (pos && (ino > pos->s_ino)) | 873 | while (pos && (ino > pos->s_ino)) |
880 | pos = pos->s_sibling; | 874 | pos = pos->s_sibling; |
881 | } | 875 | } |
882 | while (pos && pos->s_ns != ns) | 876 | while (pos && pos->s_ns && pos->s_ns != ns) |
883 | pos = pos->s_sibling; | 877 | pos = pos->s_sibling; |
884 | return pos; | 878 | return pos; |
885 | } | 879 | } |
@@ -890,7 +884,7 @@ static struct sysfs_dirent *sysfs_dir_next_pos(const void *ns, | |||
890 | pos = sysfs_dir_pos(ns, parent_sd, ino, pos); | 884 | pos = sysfs_dir_pos(ns, parent_sd, ino, pos); |
891 | if (pos) | 885 | if (pos) |
892 | pos = pos->s_sibling; | 886 | pos = pos->s_sibling; |
893 | while (pos && pos->s_ns != ns) | 887 | while (pos && pos->s_ns && pos->s_ns != ns) |
894 | pos = pos->s_sibling; | 888 | pos = pos->s_sibling; |
895 | return pos; | 889 | return pos; |
896 | } | 890 | } |
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c index cf2bad1462ea..bbd77e95cf7f 100644 --- a/fs/sysfs/inode.c +++ b/fs/sysfs/inode.c | |||
@@ -335,6 +335,8 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const cha | |||
335 | sysfs_addrm_start(&acxt, dir_sd); | 335 | sysfs_addrm_start(&acxt, dir_sd); |
336 | 336 | ||
337 | sd = sysfs_find_dirent(dir_sd, ns, name); | 337 | sd = sysfs_find_dirent(dir_sd, ns, name); |
338 | if (sd && (sd->s_ns != ns)) | ||
339 | sd = NULL; | ||
338 | if (sd) | 340 | if (sd) |
339 | sysfs_remove_one(&acxt, sd); | 341 | sysfs_remove_one(&acxt, sd); |
340 | 342 | ||