Browse files

f2fs: use _safe() version of list_for_each

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 <>
Reviewed-by: Dmitry Torokhov <>
Signed-off-by: Jaegeuk Kim <>
  • Loading branch information...
1 parent 9af45ef commit d8b79b2f94600262fcfbffbe3df7fd3c83c6c51b Dan Carpenter committed with Jaegeuk Kim Jan 20, 2013
Showing with 3 additions and 4 deletions.
  1. +3 −4 fs/f2fs/recovery.c
@@ -173,10 +173,9 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head)
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) {
kmem_cache_free(fsync_entry_slab, entry);

0 comments on commit d8b79b2

Please sign in to comment.