From: Ryusuke Konishi Date: Mon, 22 Mar 2010 10:33:43 +0000 (+0900) Subject: nilfs2: fix imperfect completion wait in nilfs_wait_on_logs X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d067633b4483f3c7d971d8f889f35340a8635bb5;p=sagit-ice-cold%2Fkernel_xiaomi_msm8998.git nilfs2: fix imperfect completion wait in nilfs_wait_on_logs nilfs_wait_on_logs has a potential to slip out before completion of all bio requests when it met an error. This synchronization fault may cause unexpected results, for instance, violative access to freed segment buffers from an end-bio callback routine. This fixes the issue by ensuring that nilfs_wait_on_logs waits all given logs. Signed-off-by: Ryusuke Konishi --- diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c index 636eaafd6ea2..6129a431aa34 100644 --- a/fs/nilfs2/segbuf.c +++ b/fs/nilfs2/segbuf.c @@ -323,14 +323,14 @@ int nilfs_write_logs(struct list_head *logs, struct the_nilfs *nilfs) int nilfs_wait_on_logs(struct list_head *logs) { struct nilfs_segment_buffer *segbuf; - int err; + int err, ret = 0; list_for_each_entry(segbuf, logs, sb_list) { err = nilfs_segbuf_wait(segbuf); - if (err) - return err; + if (err && !ret) + ret = err; } - return 0; + return ret; } /*