Commit 68bf8611076a8e4bee8bc8d03ff28bd1e9a9c631
1 parent
3d268c9b13
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
overlayfs: make ovl_cache_entry->name an array instead of pointer
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 1 changed file with 5 additions and 6 deletions Side-by-side Diff
fs/overlayfs/readdir.c
... | ... | @@ -18,13 +18,13 @@ |
18 | 18 | #include "overlayfs.h" |
19 | 19 | |
20 | 20 | struct ovl_cache_entry { |
21 | - const char *name; | |
22 | 21 | unsigned int len; |
23 | 22 | unsigned int type; |
24 | 23 | u64 ino; |
25 | 24 | bool is_whiteout; |
26 | 25 | struct list_head l_node; |
27 | 26 | struct rb_node node; |
27 | + char name[]; | |
28 | 28 | }; |
29 | 29 | |
30 | 30 | struct ovl_dir_cache { |
31 | 31 | |
32 | 32 | |
... | ... | @@ -82,13 +82,12 @@ |
82 | 82 | u64 ino, unsigned int d_type) |
83 | 83 | { |
84 | 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 | 88 | if (p) { |
88 | - char *name_copy = (char *) (p + 1); | |
89 | - memcpy(name_copy, name, len); | |
90 | - name_copy[len] = '\0'; | |
91 | - p->name = name_copy; | |
89 | + memcpy(p->name, name, len); | |
90 | + p->name[len] = '\0'; | |
92 | 91 | p->len = len; |
93 | 92 | p->type = d_type; |
94 | 93 | p->ino = ino; |
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965
-
mentioned in commit c20965