mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-09 15:29:16 +00:00
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>
This commit is contained in:
parent
69753a0f14
commit
5da4e68944
@ -164,34 +164,28 @@ static int dev_mkdir(const char *name, mode_t mode)
|
|||||||
|
|
||||||
static int create_path(const char *nodepath)
|
static int create_path(const char *nodepath)
|
||||||
{
|
{
|
||||||
|
char *path;
|
||||||
|
char *s;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
err = dev_mkdir(nodepath, 0755);
|
/* parent directories do not exist, create them */
|
||||||
if (err == -ENOENT) {
|
path = kstrdup(nodepath, GFP_KERNEL);
|
||||||
char *path;
|
if (!path)
|
||||||
char *s;
|
return -ENOMEM;
|
||||||
|
|
||||||
/* parent directories do not exist, create them */
|
s = path;
|
||||||
path = kstrdup(nodepath, GFP_KERNEL);
|
for (;;) {
|
||||||
if (!path) {
|
s = strchr(s, '/');
|
||||||
err = -ENOMEM;
|
if (!s)
|
||||||
goto out;
|
break;
|
||||||
}
|
s[0] = '\0';
|
||||||
s = path;
|
err = dev_mkdir(path, 0755);
|
||||||
for (;;) {
|
if (err && err != -EEXIST)
|
||||||
s = strchr(s, '/');
|
break;
|
||||||
if (!s)
|
s[0] = '/';
|
||||||
break;
|
s++;
|
||||||
s[0] = '\0';
|
|
||||||
err = dev_mkdir(path, 0755);
|
|
||||||
if (err && err != -EEXIST)
|
|
||||||
break;
|
|
||||||
s[0] = '/';
|
|
||||||
s++;
|
|
||||||
}
|
|
||||||
kfree(path);
|
|
||||||
}
|
}
|
||||||
out:
|
kfree(path);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user