f2fs: use _safe() version of list_for_each
authorDan Carpenter <dan.carpenter@oracle.com>
Sun, 20 Jan 2013 15:02:58 +0000 (18:02 +0300)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Tue, 22 Jan 2013 01:49:00 +0000 (10:49 +0900)
This is calling list_del() inside a loop which is a problem when we try
move to the next item on the list.  I've converted it to use the _safe
version.  And also, as a cleanup, I've converted it to use
list_for_each_entry instead of list_for_each.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/recovery.c

index 6cc046d368158d541a589aaa476286d7248541de..f42e4060b3991c140fd7e3e3de58d40d30dfcbc4 100644 (file)
@@ -173,10 +173,9 @@ out:
 static void destroy_fsync_dnodes(struct f2fs_sb_info *sbi,
                                        struct list_head *head)
 {
-       struct list_head *this;
-       struct fsync_inode_entry *entry;
-       list_for_each(this, head) {
-               entry = list_entry(this, struct fsync_inode_entry, list);
+       struct fsync_inode_entry *entry, *tmp;
+
+       list_for_each_entry_safe(entry, tmp, head, list) {
                iput(entry->inode);
                list_del(&entry->list);
                kmem_cache_free(fsync_entry_slab, entry);