From c1399b62aaa71a3da498b5fa67adb25e59181ab0 Mon Sep 17 00:00:00 2001 From: Charles Manning Date: Thu, 1 Jul 2010 12:25:59 +1200 Subject: [PATCH 1/1] yaffs Fix readdir locking yaffs_EndSearch() should have been called with yaffs locked. Signed-off-by: Charles Manning --- yaffs_fs.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/yaffs_fs.c b/yaffs_fs.c index 9469e1b..031c390 100644 --- a/yaffs_fs.c +++ b/yaffs_fs.c @@ -1442,7 +1442,7 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) sc = yaffs_NewSearch(obj); if(!sc){ retVal = -ENOMEM; - goto unlock_out; + goto out; } T(YAFFS_TRACE_OS, (TSTR("yaffs_readdir: starting at %d\n"), (int)offset)); @@ -1452,8 +1452,10 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) (TSTR("yaffs_readdir: entry . ino %d \n"), (int)inode->i_ino)); yaffs_GrossUnlock(dev); - if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR) < 0) + if (filldir(dirent, ".", 1, offset, inode->i_ino, DT_DIR) < 0){ + yaffs_GrossLock(dev); goto out; + } yaffs_GrossLock(dev); offset++; f->f_pos++; @@ -1464,8 +1466,10 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) (int)f->f_dentry->d_parent->d_inode->i_ino)); yaffs_GrossUnlock(dev); if (filldir(dirent, "..", 2, offset, - f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0) + f->f_dentry->d_parent->d_inode->i_ino, DT_DIR) < 0){ + yaffs_GrossLock(dev); goto out; + } yaffs_GrossLock(dev); offset++; f->f_pos++; @@ -1501,8 +1505,10 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) strlen(name), offset, this_inode, - this_type) < 0) + this_type) < 0){ + yaffs_GrossLock(dev); goto out; + } yaffs_GrossLock(dev); @@ -1512,12 +1518,10 @@ static int yaffs_readdir(struct file *f, void *dirent, filldir_t filldir) yaffs_SearchAdvance(sc); } -unlock_out: +out: + yaffs_EndSearch(sc); yaffs_DeviceToContext(dev)->readdirProcess = NULL; - yaffs_GrossUnlock(dev); -out: - yaffs_EndSearch(sc); return retVal; } -- 2.30.2