diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2011-06-27 16:37:12 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2011-07-20 01:44:11 -0400 |
commit | 5da4e689449ad99ab31cf2208d99eddfce0498ba (patch) | |
tree | 5cd8ccc145b8b29b3a63dd6252ee921d8e01379b /drivers/base/devtmpfs.c | |
parent | 69753a0f14d3cb2e8a70e559ef8d409e4deeac8a (diff) |
devtmpfs: get rid of bogus mkdir in create_path()
We do _NOT_ want to mkdir the path itself - we are preparing to
mknod it, after all. Normally it'll fail with -ENOENT and
just do nothing, but if somebody has created the parent in
the meanwhile, we'll get buggered...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/base/devtmpfs.c')
-rw-r--r-- | drivers/base/devtmpfs.c | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index a49897d05325..6d678c99512e 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -164,34 +164,28 @@ static int dev_mkdir(const char *name, mode_t mode) static int create_path(const char *nodepath) { + char *path; + char *s; int err; - err = dev_mkdir(nodepath, 0755); - if (err == -ENOENT) { - char *path; - char *s; + /* parent directories do not exist, create them */ + path = kstrdup(nodepath, GFP_KERNEL); + if (!path) + return -ENOMEM; - /* parent directories do not exist, create them */ - path = kstrdup(nodepath, GFP_KERNEL); - if (!path) { - err = -ENOMEM; - goto out; - } - s = path; - for (;;) { - s = strchr(s, '/'); - if (!s) - break; - s[0] = '\0'; - err = dev_mkdir(path, 0755); - if (err && err != -EEXIST) - break; - s[0] = '/'; - s++; - } - kfree(path); + s = path; + for (;;) { + s = strchr(s, '/'); + if (!s) + break; + s[0] = '\0'; + err = dev_mkdir(path, 0755); + if (err && err != -EEXIST) + break; + s[0] = '/'; + s++; } -out: + kfree(path); return err; } |