Skip to content

Commit

Permalink
overlayfs: make ovl_cache_entry->name an array instead of pointer
Browse files Browse the repository at this point in the history
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Oct 25, 2014
1 parent 3d268c9 commit 68bf861
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions fs/overlayfs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
#include "overlayfs.h"

struct ovl_cache_entry {
const char *name;
unsigned int len;
unsigned int type;
u64 ino;
bool is_whiteout;
struct list_head l_node;
struct rb_node node;
char name[];
};

struct ovl_dir_cache {
Expand Down Expand Up @@ -82,13 +82,12 @@ static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len,
u64 ino, unsigned int d_type)
{
struct ovl_cache_entry *p;
size_t size = offsetof(struct ovl_cache_entry, name[len + 1]);

p = kmalloc(sizeof(*p) + len + 1, GFP_KERNEL);
p = kmalloc(size, GFP_KERNEL);
if (p) {
char *name_copy = (char *) (p + 1);
memcpy(name_copy, name, len);
name_copy[len] = '\0';
p->name = name_copy;
memcpy(p->name, name, len);
p->name[len] = '\0';
p->len = len;
p->type = d_type;
p->ino = ino;
Expand Down

0 comments on commit 68bf861

Please sign in to comment.