jffs2: remove from wait queue after schedule()
authorLi Zefan <lizefan@huawei.com>
Wed, 12 Feb 2014 20:44:57 +0000 (12:44 -0800)
committerBrian Norris <computersforpeace@gmail.com>
Tue, 11 Mar 2014 05:42:27 +0000 (22:42 -0700)
@wait is a local variable, so if we don't remove it from the wait queue
list, later wake_up() may end up accessing invalid memory.

This was spotted by eyes.

Signed-off-by: Li Zefan <lizefan@huawei.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
fs/jffs2/nodemgmt.c

index 03310721712f7885aa043c1c2f88421d0a80649b..bbae5b1a833a24a724eaa633d9ffd217e7762b88 100644 (file)
@@ -179,6 +179,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t minsize,
                                        spin_unlock(&c->erase_completion_lock);
 
                                        schedule();
+                                       remove_wait_queue(&c->erase_wait, &wait);
                                } else
                                        spin_unlock(&c->erase_completion_lock);
                        } else if (ret)