summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorEric Sandeen2013-01-31 01:55:01 +0100
committerJosef Bacik2013-02-20 18:59:26 +0100
commit063d006fa06fbf73fab370921120380333a33e85 (patch)
tree5a6650052c7409fc8895762fcc7ef8015e5088b8 /fs/btrfs/volumes.c
parentbtrfs: remove unnecessary DEFINE_WAIT() declarations (diff)
downloadkernel-qcow2-linux-063d006fa06fbf73fab370921120380333a33e85.tar.gz
kernel-qcow2-linux-063d006fa06fbf73fab370921120380333a33e85.tar.xz
kernel-qcow2-linux-063d006fa06fbf73fab370921120380333a33e85.zip
btrfs: ensure we don't overrun devices_info[] in __btrfs_alloc_chunk
WARN_ON isn't enough, we need to stop the loop if for any reason we would overrun the devices_info array. I tried to track down the connection between the length of the alloc_devices list and the rw_devices counter but it wasn't immediately obvious, so be defensive about it. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index c7843349c795..305b6a63ab1f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -3734,12 +3734,16 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
if (max_avail < BTRFS_STRIPE_LEN * dev_stripes)
continue;
+ if (ndevs == fs_devices->rw_devices) {
+ WARN(1, "%s: found more than %llu devices\n",
+ __func__, fs_devices->rw_devices);
+ break;
+ }
devices_info[ndevs].dev_offset = dev_offset;
devices_info[ndevs].max_avail = max_avail;
devices_info[ndevs].total_avail = total_avail;
devices_info[ndevs].dev = device;
++ndevs;
- WARN_ON(ndevs > fs_devices->rw_devices);
}
/*