Liu Bo
876d2cf141
Btrfs: fix double free of fs root
I got this warning while mounting a btrfs image,
[ 3020.509606] ------------[ cut here ]------------
[ 3020.510107] WARNING: CPU: 3 PID: 5581 at lib/idr.c:1051 ida_remove+0xca/0x190
[ 3020.510853] ida_remove called for id=42 which is not allocated.
[ 3020.511466] Modules linked in:
[ 3020.511802] CPU: 3 PID: 5581 Comm: mount Not tainted 4.7.0-rc5+ #274
[ 3020.512438] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.8.2-20150714_191134- 04/01/2014
[ 3020.513385] 0000000000000286 0000000021295d86 ffff88006c66b8f0 ffffffff8182ba5a
[ 3020.514153] 0000000000000000 0000000000000009 ffff88006c66b930 ffffffff810e0ed7
[ 3020.514928] 0000041b00000000 ffffffff8289a8c0 ffff88007f437880 0000000000000000
[ 3020.515717] Call Trace:
[ 3020.515965] [<ffffffff8182ba5a>] dump_stack+0xc9/0x13f
[ 3020.516487] [<ffffffff810e0ed7>] __warn+0x147/0x160
[ 3020.517005] [<ffffffff810e0f4f>] warn_slowpath_fmt+0x5f/0x80
[ 3020.517572] [<ffffffff8182e6ca>] ida_remove+0xca/0x190
[ 3020.518075] [<ffffffff813a2bcc>] free_anon_bdev+0x2c/0x60
[ 3020.518609] [<ffffffff81657a9f>] free_fs_root+0x13f/0x160
[ 3020.519138] [<ffffffff8165c679>] btrfs_get_fs_root+0x379/0x3d0
[ 3020.519710] [<ffffffff81e6e975>] ? __mutex_unlock_slowpath+0x155/0x2c0
[ 3020.520366] [<ffffffff816615b1>] open_ctree+0x2e91/0x3200
[ 3020.520965] [<ffffffff8161ede2>] btrfs_mount+0x1322/0x15b0
[ 3020.521536] [<ffffffff81e60e74>] ? kmemleak_alloc_percpu+0x44/0x170
[ 3020.522167] [<ffffffff8115f5e1>] ? lockdep_init_map+0x61/0x210
[ 3020.522780] [<ffffffff813a4f59>] mount_fs+0x49/0x2c0
[ 3020.523305] [<ffffffff813d840c>] vfs_kern_mount+0xac/0x1b0
[ 3020.523872] [<ffffffff8161dee1>] btrfs_mount+0x421/0x15b0
[ 3020.524402] [<ffffffff81e60e74>] ? kmemleak_alloc_percpu+0x44/0x170
[ 3020.525045] [<ffffffff8115f5e1>] ? lockdep_init_map+0x61/0x210
[ 3020.525657] [<ffffffff8115f5e1>] ? lockdep_init_map+0x61/0x210
[ 3020.526289] [<ffffffff813a4f59>] mount_fs+0x49/0x2c0
[ 3020.526803] [<ffffffff813d840c>] vfs_kern_mount+0xac/0x1b0
[ 3020.527365] [<ffffffff813dc27a>] do_mount+0x41a/0x1770
[ 3020.527899] [<ffffffff812e800d>] ? strndup_user+0x6d/0xc0
[ 3020.528447] [<ffffffff812e7f68>] ? memdup_user+0x78/0xb0
[ 3020.528987] [<ffffffff813ddad0>] SyS_mount+0x150/0x160
[ 3020.529493] [<ffffffff81e72b7c>] entry_SYSCALL_64_fastpath+0x1f/0xbd
It turns out that we free fs root twice, btrfs_init_fs_root() calls
free_anon_bdev(root->anon_dev) and later then btrfs_get_fs_root() cals
free_fs_root which does another free_anon_bdev() and it ends up with the
above warning.
Instead of reset root->anon_dev to 0 after free_anon_bdev(), we can let
btrfs_init_fs_root() return directly since its callers have already done
the free job by calling free_fs_root().
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Reviewed-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-07-26 13:52:25 +02:00
..
2016-06-30 23:28:09 -04:00
2016-01-20 17:09:18 -08:00
2016-05-28 16:50:24 -07:00
2016-05-27 15:26:11 -07:00
2016-06-24 17:23:52 -07:00
2016-05-23 17:04:14 -07:00
2016-05-09 11:41:14 -04:00
2016-07-26 13:52:25 +02:00
2016-06-01 10:29:39 +02:00
2016-07-01 15:20:11 -07:00
2016-06-24 12:05:52 -05:00
2016-05-02 19:49:29 -04:00
2016-05-09 11:41:13 -04:00
2016-05-09 11:41:14 -04:00
2016-05-07 10:32:33 -07:00
2016-06-15 04:56:35 -07:00
2016-06-05 10:36:01 -07:00
2016-04-04 10:41:08 -07:00
2016-06-10 12:10:02 -07:00
2016-05-20 17:58:30 -07:00
2016-05-20 17:58:30 -07:00
2016-05-17 17:05:30 -07:00
2016-05-02 19:49:29 -04:00
2016-05-27 17:14:05 -07:00
2016-05-27 17:14:05 -07:00
2016-05-27 15:39:43 -04:00
2016-05-17 15:05:23 -07:00
2016-05-09 11:41:14 -04:00
2016-06-01 10:29:09 +02:00
2016-06-30 13:10:49 +02:00
2016-05-27 17:14:05 -07:00
2016-05-27 20:09:16 -04:00
2016-05-27 15:39:43 -04:00
2016-05-12 19:49:30 -04:00
2016-05-28 16:50:24 -07:00
2016-04-04 10:41:08 -07:00
2016-05-11 00:00:29 -04:00
2016-06-24 17:23:52 -07:00
2016-05-27 15:39:43 -04:00
2016-05-27 15:39:43 -04:00
2016-05-27 20:09:16 -04:00
2016-06-30 16:35:07 -04:00
2016-05-09 11:42:19 -04:00
2016-05-02 19:49:32 -04:00
2016-04-04 10:41:08 -07:00
2016-06-28 16:55:34 -04:00
2016-06-24 12:11:52 -04:00
2016-06-24 17:23:52 -07:00
2016-05-19 19:12:14 -07:00
2016-05-01 19:58:39 -04:00
2016-06-24 17:23:52 -07:00
2016-05-09 11:41:14 -04:00
2016-05-09 11:41:14 -04:00
2016-05-27 15:39:43 -04:00
2016-07-03 09:39:31 +02:00
2016-06-10 12:10:02 -07:00
2016-04-04 10:41:08 -07:00
2016-05-09 11:41:14 -04:00
2016-05-09 11:41:14 -04:00
2016-04-26 12:00:48 -04:00
2016-05-20 17:58:30 -07:00
2016-06-19 07:05:14 -10:00
2016-05-09 11:41:15 -04:00
2016-05-09 11:41:15 -04:00
2015-11-13 21:53:18 -08:00
2016-05-02 19:49:32 -04:00
2016-01-22 18:04:28 -05:00
2016-06-23 00:29:53 +02:00
2016-05-19 13:00:35 +02:00
2016-05-02 19:49:32 -04:00
2016-05-27 17:14:05 -07:00
2016-05-23 17:04:14 -07:00
2016-01-22 18:04:28 -05:00
2016-05-27 20:09:16 -04:00
2016-05-28 16:34:59 -07:00
2016-06-07 22:07:09 -04:00
2016-06-07 22:07:09 -04:00
2016-05-27 15:26:11 -07:00
2016-01-22 18:04:28 -05:00
2016-05-26 19:34:26 -07:00
2016-05-19 19:12:14 -07:00
2016-03-29 10:11:44 -07:00
2016-02-14 14:25:59 -08:00
2016-05-24 12:55:26 -07:00
2016-06-07 22:07:09 -04:00
2016-06-27 12:18:44 -07:00
2016-06-20 10:07:42 -04:00
2016-05-27 14:49:37 -07:00
2016-03-22 15:36:02 -07:00
2016-05-19 19:12:14 -07:00
2016-05-23 17:04:14 -07:00
2016-01-09 02:55:37 -05:00
2016-03-22 15:36:02 -07:00
2016-05-02 19:49:28 -04:00
2016-01-19 12:02:23 -05:00
2016-05-20 17:58:30 -07:00
2016-05-02 19:49:28 -04:00
2016-06-10 11:32:47 -04:00
2016-01-22 18:04:28 -05:00
2016-05-19 15:13:17 -06:00
2016-05-23 17:04:14 -07:00
2016-06-20 17:11:29 -04:00
2016-07-01 10:24:18 -04:00
2016-03-26 12:59:04 -07:00
2016-02-22 22:44:04 -05:00
2016-04-04 10:41:08 -07:00
2016-06-07 20:41:36 -07:00
2016-07-01 15:20:11 -07:00
2016-05-17 14:41:03 -07:00
2016-04-04 10:41:08 -07:00
2016-05-05 09:54:45 -05:00
2016-06-24 12:11:34 -04:00
2016-03-16 13:09:08 -04:00
2016-05-18 11:46:23 -07:00
2016-05-26 00:13:25 -04:00
2016-05-19 19:12:14 -07:00
2016-04-14 12:56:09 -07:00
2016-05-11 00:00:29 -04:00
2016-01-16 11:17:23 -08:00
2016-04-18 11:18:55 +02:00
2016-04-04 10:41:08 -07:00
2016-01-17 11:13:55 +01:00
2016-05-20 17:58:30 -07:00
2016-01-22 18:04:28 -05:00
2016-05-27 20:09:16 -04:00