Skip to content

Commit 5f30fc9

Browse files
Hugh Dickinstorvalds
authored andcommitted
lib/radix-tree.c: swapoff tmpfs radix_tree: remember to rcu_read_unlock
Running fsx on tmpfs with concurrent memhog-swapoff-swapon, lots of BUG: sleeping function called from invalid context at kernel/fork.c:606 in_atomic(): 0, irqs_disabled(): 0, pid: 1394, name: swapoff 1 lock held by swapoff/1394: #0: (rcu_read_lock){.+.+.+}, at: [<ffffffff812520a1>] radix_tree_locate_item+0x1f/0x2b6 followed by ================================================ [ BUG: lock held when returning to user space! ] 3.14.0-rc1 #3 Not tainted ------------------------------------------------ swapoff/1394 is leaving the kernel with locks still held! 1 lock held by swapoff/1394: #0: (rcu_read_lock){.+.+.+}, at: [<ffffffff812520a1>] radix_tree_locate_item+0x1f/0x2b6 after which the system recovered nicely. Whoops, I long ago forgot the rcu_read_unlock() on one unlikely branch. Fixes e504f3f ("tmpfs radix_tree: locate_item to speed up swapoff") Signed-off-by: Hugh Dickins <[email protected]> Cc: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 3b7a641 commit 5f30fc9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/radix-tree.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,8 +1253,10 @@ unsigned long radix_tree_locate_item(struct radix_tree_root *root, void *item)
12531253

12541254
node = indirect_to_ptr(node);
12551255
max_index = radix_tree_maxindex(node->height);
1256-
if (cur_index > max_index)
1256+
if (cur_index > max_index) {
1257+
rcu_read_unlock();
12571258
break;
1259+
}
12581260

12591261
cur_index = __locate(node, item, cur_index, &found_index);
12601262
rcu_read_unlock();

0 commit comments

Comments
 (0)