public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] f2fs: use _safe() version of list_for_each
@ 2013-01-20 15:02 Dan Carpenter
  2013-01-21  0:39 ` Namjae Jeon
  2013-01-21  8:32 ` Dmitry Torokhov
  0 siblings, 2 replies; 10+ messages in thread
From: Dan Carpenter @ 2013-01-20 15:02 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel, linux-kernel, kernel-janitors

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>
---
Static analysis stuff.  Untested.  Please review carefully.

diff --git a/fs/f2fs/recovery.c b/fs/f2fs/recovery.c
index 6cc046d..f42e406 100644
--- a/fs/f2fs/recovery.c
+++ b/fs/f2fs/recovery.c
@@ -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);

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-01-21 12:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-20 15:02 [patch] f2fs: use _safe() version of list_for_each Dan Carpenter
2013-01-21  0:39 ` Namjae Jeon
2013-01-21  8:25   ` Dan Carpenter
2013-01-21  8:34   ` Dmitry Torokhov
2013-01-21  8:32 ` Dmitry Torokhov
2013-01-21  9:20   ` Jaegeuk Kim
2013-01-21 10:27     ` Namjae Jeon
2013-01-21 10:37       ` Julia Lawall
2013-01-21 11:24       ` Dan Carpenter
2013-01-21 12:04         ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox