Commit c2096537 authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Al Viro

ovl: fix check for cursor

ovl_cache_entry.name is now an array not a pointer, so it makes no sense
test for it being NULL.

Detected by coverity.

From: Miklos Szeredi <mszeredi@suse.cz>
Fixes: 68bf8611 ("overlayfs: make ovl_cache_entry->name an array instead of
+pointer")
Signed-off-by: default avatarMiklos Szeredi <mszeredi@suse.cz>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent d45f00ae
...@@ -21,9 +21,10 @@ struct ovl_cache_entry { ...@@ -21,9 +21,10 @@ struct ovl_cache_entry {
unsigned int len; unsigned int len;
unsigned int type; unsigned int type;
u64 ino; u64 ino;
bool is_whiteout;
struct list_head l_node; struct list_head l_node;
struct rb_node node; struct rb_node node;
bool is_whiteout;
bool is_cursor;
char name[]; char name[];
}; };
...@@ -251,7 +252,7 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir, ...@@ -251,7 +252,7 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
mutex_lock(&dir->d_inode->i_mutex); mutex_lock(&dir->d_inode->i_mutex);
list_for_each_entry(p, rdd->list, l_node) { list_for_each_entry(p, rdd->list, l_node) {
if (!p->name) if (p->is_cursor)
continue; continue;
if (p->type != DT_CHR) if (p->type != DT_CHR)
...@@ -307,7 +308,6 @@ static inline int ovl_dir_read_merged(struct path *upperpath, ...@@ -307,7 +308,6 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
} }
out: out:
return err; return err;
} }
static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos) static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
...@@ -316,7 +316,7 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos) ...@@ -316,7 +316,7 @@ static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos)
loff_t off = 0; loff_t off = 0;
list_for_each_entry(p, &od->cache->entries, l_node) { list_for_each_entry(p, &od->cache->entries, l_node) {
if (!p->name) if (p->is_cursor)
continue; continue;
if (off >= pos) if (off >= pos)
break; break;
...@@ -389,7 +389,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx) ...@@ -389,7 +389,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node); p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node);
/* Skip cursors */ /* Skip cursors */
if (p->name) { if (!p->is_cursor) {
if (!p->is_whiteout) { if (!p->is_whiteout) {
if (!dir_emit(ctx, p->name, p->len, p->ino, p->type)) if (!dir_emit(ctx, p->name, p->len, p->ino, p->type))
break; break;
...@@ -519,6 +519,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file) ...@@ -519,6 +519,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
od->realfile = realfile; od->realfile = realfile;
od->is_real = (type != OVL_PATH_MERGE); od->is_real = (type != OVL_PATH_MERGE);
od->is_upper = (type != OVL_PATH_LOWER); od->is_upper = (type != OVL_PATH_LOWER);
od->cursor.is_cursor = true;
file->private_data = od; file->private_data = od;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment