diff options
Diffstat (limited to 'drivers/base')
| -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) | |||
| 164 | 164 | ||
| 165 | static int create_path(const char *nodepath) | 165 | static int create_path(const char *nodepath) |
| 166 | { | 166 | { |
| 167 | char *path; | ||
| 168 | char *s; | ||
| 167 | int err; | 169 | int err; |
| 168 | 170 | ||
| 169 | err = dev_mkdir(nodepath, 0755); | 171 | /* parent directories do not exist, create them */ |
| 170 | if (err == -ENOENT) { | 172 | path = kstrdup(nodepath, GFP_KERNEL); |
| 171 | char *path; | 173 | if (!path) |
| 172 | char *s; | 174 | return -ENOMEM; |
| 173 | 175 | ||
| 174 | /* parent directories do not exist, create them */ | 176 | s = path; |
| 175 | path = kstrdup(nodepath, GFP_KERNEL); | 177 | for (;;) { |
| 176 | if (!path) { | 178 | s = strchr(s, '/'); |
| 177 | err = -ENOMEM; | 179 | if (!s) |
| 178 | goto out; | 180 | break; |
| 179 | } | 181 | s[0] = '\0'; |
| 180 | s = path; | 182 | err = dev_mkdir(path, 0755); |
| 181 | for (;;) { | 183 | if (err && err != -EEXIST) |
| 182 | s = strchr(s, '/'); | 184 | break; |
| 183 | if (!s) | 185 | s[0] = '/'; |
| 184 | break; | 186 | s++; |
| 185 | s[0] = '\0'; | ||
| 186 | err = dev_mkdir(path, 0755); | ||
| 187 | if (err && err != -EEXIST) | ||
| 188 | break; | ||
| 189 | s[0] = '/'; | ||
| 190 | s++; | ||
| 191 | } | ||
| 192 | kfree(path); | ||
| 193 | } | 187 | } |
| 194 | out: | 188 | kfree(path); |
| 195 | return err; | 189 | return err; |
| 196 | } | 190 | } |
| 197 | 191 | ||
