diff options
| -rw-r--r-- | fs/overlayfs/readdir.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c index b7d9fb098840..9c9872be2c72 100644 --- a/fs/overlayfs/readdir.c +++ b/fs/overlayfs/readdir.c | |||
| @@ -18,13 +18,13 @@ | |||
| 18 | #include "overlayfs.h" | 18 | #include "overlayfs.h" |
| 19 | 19 | ||
| 20 | struct ovl_cache_entry { | 20 | struct ovl_cache_entry { |
| 21 | const char *name; | ||
| 22 | unsigned int len; | 21 | unsigned int len; |
| 23 | unsigned int type; | 22 | unsigned int type; |
| 24 | u64 ino; | 23 | u64 ino; |
| 25 | bool is_whiteout; | 24 | bool is_whiteout; |
| 26 | struct list_head l_node; | 25 | struct list_head l_node; |
| 27 | struct rb_node node; | 26 | struct rb_node node; |
| 27 | char name[]; | ||
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | struct ovl_dir_cache { | 30 | struct ovl_dir_cache { |
| @@ -82,13 +82,12 @@ static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len, | |||
| 82 | u64 ino, unsigned int d_type) | 82 | u64 ino, unsigned int d_type) |
| 83 | { | 83 | { |
| 84 | struct ovl_cache_entry *p; | 84 | struct ovl_cache_entry *p; |
| 85 | size_t size = offsetof(struct ovl_cache_entry, name[len + 1]); | ||
| 85 | 86 | ||
| 86 | p = kmalloc(sizeof(*p) + len + 1, GFP_KERNEL); | 87 | p = kmalloc(size, GFP_KERNEL); |
| 87 | if (p) { | 88 | if (p) { |
| 88 | char *name_copy = (char *) (p + 1); | 89 | memcpy(p->name, name, len); |
| 89 | memcpy(name_copy, name, len); | 90 | p->name[len] = '\0'; |
| 90 | name_copy[len] = '\0'; | ||
| 91 | p->name = name_copy; | ||
| 92 | p->len = len; | 91 | p->len = len; |
| 93 | p->type = d_type; | 92 | p->type = d_type; |
| 94 | p->ino = ino; | 93 | p->ino = ino; |
