aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2014-10-27 08:48:48 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2014-10-28 18:31:54 -0400
commitc2096537d40f026672c4c6adfcd7247ce5799604 (patch)
tree7b9b23927f0fe340bd1866269b10b77974c9bb74
parentd45f00ae43e63eff1b3d79df20610ae1ef645ebd (diff)
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: 68bf8611076a ("overlayfs: make ovl_cache_entry->name an array instead of +pointer") Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/overlayfs/readdir.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/fs/overlayfs/readdir.c b/fs/overlayfs/readdir.c
index 8c8ce9d87ba3..3fbf0d306e12 100644
--- a/fs/overlayfs/readdir.c
+++ b/fs/overlayfs/readdir.c
@@ -21,9 +21,10 @@ struct ovl_cache_entry {
21 unsigned int len; 21 unsigned int len;
22 unsigned int type; 22 unsigned int type;
23 u64 ino; 23 u64 ino;
24 bool is_whiteout;
25 struct list_head l_node; 24 struct list_head l_node;
26 struct rb_node node; 25 struct rb_node node;
26 bool is_whiteout;
27 bool is_cursor;
27 char name[]; 28 char name[];
28}; 29};
29 30
@@ -251,7 +252,7 @@ static int ovl_dir_mark_whiteouts(struct dentry *dir,
251 252
252 mutex_lock(&dir->d_inode->i_mutex); 253 mutex_lock(&dir->d_inode->i_mutex);
253 list_for_each_entry(p, rdd->list, l_node) { 254 list_for_each_entry(p, rdd->list, l_node) {
254 if (!p->name) 255 if (p->is_cursor)
255 continue; 256 continue;
256 257
257 if (p->type != DT_CHR) 258 if (p->type != DT_CHR)
@@ -307,7 +308,6 @@ static inline int ovl_dir_read_merged(struct path *upperpath,
307 } 308 }
308out: 309out:
309 return err; 310 return err;
310
311} 311}
312 312
313static void ovl_seek_cursor(struct ovl_dir_file *od, loff_t pos) 313static 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 loff_t off = 0; 316 loff_t off = 0;
317 317
318 list_for_each_entry(p, &od->cache->entries, l_node) { 318 list_for_each_entry(p, &od->cache->entries, l_node) {
319 if (!p->name) 319 if (p->is_cursor)
320 continue; 320 continue;
321 if (off >= pos) 321 if (off >= pos)
322 break; 322 break;
@@ -389,7 +389,7 @@ static int ovl_iterate(struct file *file, struct dir_context *ctx)
389 389
390 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node); 390 p = list_entry(od->cursor.l_node.next, struct ovl_cache_entry, l_node);
391 /* Skip cursors */ 391 /* Skip cursors */
392 if (p->name) { 392 if (!p->is_cursor) {
393 if (!p->is_whiteout) { 393 if (!p->is_whiteout) {
394 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type)) 394 if (!dir_emit(ctx, p->name, p->len, p->ino, p->type))
395 break; 395 break;
@@ -519,6 +519,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
519 od->realfile = realfile; 519 od->realfile = realfile;
520 od->is_real = (type != OVL_PATH_MERGE); 520 od->is_real = (type != OVL_PATH_MERGE);
521 od->is_upper = (type != OVL_PATH_LOWER); 521 od->is_upper = (type != OVL_PATH_LOWER);
522 od->cursor.is_cursor = true;
522 file->private_data = od; 523 file->private_data = od;
523 524
524 return 0; 525 return 0;