Skip to content

Commit

Permalink
devtmpfs: get rid of bogus mkdir in create_path()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Al Viro committed Jul 20, 2011
1 parent 69753a0 commit 5da4e68
Showing 1 changed file with 18 additions and 24 deletions.
42 changes: 18 additions & 24 deletions drivers/base/devtmpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5da4e68

Please sign in to comment.