summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-12-20 09:58:10 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-12-20 09:58:10 +0100
commit236c9ad1f87088bb07ebdd136b8432f83dfd1e14 (patch)
treeae8713c9878593521f2cb517891f123f178fdd83 /fs/btrfs/disk-io.c
parentusb: misc: ehset: Rework test mode entry (diff)
parentLinux 5.16-rc6 (diff)
downloadlinux-236c9ad1f87088bb07ebdd136b8432f83dfd1e14.tar.xz
linux-236c9ad1f87088bb07ebdd136b8432f83dfd1e14.zip
Merge 5.16-rc6 into usb-next
We need the USB fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 514ead6e93b6..b3f2e2232326 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1732,6 +1732,14 @@ again:
}
return root;
fail:
+ /*
+ * If our caller provided us an anonymous device, then it's his
+ * responsability to free it in case we fail. So we have to set our
+ * root's anon_dev to 0 to avoid a double free, once by btrfs_put_root()
+ * and once again by our caller.
+ */
+ if (anon_dev)
+ root->anon_dev = 0;
btrfs_put_root(root);
return ERR_PTR(ret);
}