Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 68bf8611 authored by Al Viro's avatar Al Viro
Browse files

overlayfs: make ovl_cache_entry->name an array instead of pointer



Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 3d268c9b
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -18,13 +18,13 @@
#include "overlayfs.h"
#include "overlayfs.h"


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


struct ovl_dir_cache {
struct ovl_dir_cache {
@@ -82,13 +82,12 @@ static struct ovl_cache_entry *ovl_cache_entry_new(const char *name, int len,
						   u64 ino, unsigned int d_type)
						   u64 ino, unsigned int d_type)
{
{
	struct ovl_cache_entry *p;
	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) {
	if (p) {
		char *name_copy = (char *) (p + 1);
		memcpy(p->name, name, len);
		memcpy(name_copy, name, len);
		p->name[len] = '\0';
		name_copy[len] = '\0';
		p->name = name_copy;
		p->len = len;
		p->len = len;
		p->type = d_type;
		p->type = d_type;
		p->ino = ino;
		p->ino = ino;