diff options
author | Tejun Heo <tj@kernel.org> | 2013-11-23 17:21:47 -0500 |
---|---|---|
committer | Pawel Osmialowski <p.osmialowsk@mcdsrvbld02.digital.local> | 2015-03-27 14:37:22 +0100 |
commit | e2db7e432d9a76042d838e824cd3e6e9131df080 (patch) | |
tree | 1ee0ba4f3c2e2001d3e868c7044c1d8be07869a4 | |
parent | 4f98dfbb50689d37120aea290750876fd76badf1 (diff) | |
download | linux-3.10-e2db7e432d9a76042d838e824cd3e6e9131df080.tar.gz linux-3.10-e2db7e432d9a76042d838e824cd3e6e9131df080.tar.bz2 linux-3.10-e2db7e432d9a76042d838e824cd3e6e9131df080.zip |
sysfs: make __sysfs_add_one() fail if the parent isn't a directory
Currently the kobject based interface guarantees that a parent
sysfs_dirent is always a directory; however, the planned kernfs
interface will be directly based on sysfs_dirents and the caller may
specify non-directory node as the parent. Add an explicit check in
__sysfs_add_one() so that such attempts fail with -EINVAL.
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/sysfs/dir.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c index 3e4bbdc5a4f..4608fc42bd2 100644 --- a/fs/sysfs/dir.c +++ b/fs/sysfs/dir.c @@ -447,6 +447,9 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd, return -EINVAL; } + if (sysfs_type(parent_sd) != SYSFS_DIR) + return -EINVAL; + sd->s_hash = sysfs_name_hash(sd->s_name, sd->s_ns); sd->s_parent = sysfs_get(parent_sd); |