From: Naohiro Aota Date: Tue, 25 Feb 2020 03:56:07 +0000 (+0900) Subject: btrfs: handle invalid profile in chunk allocation X-Git-Tag: block-5.7-2020-04-09~20^2~76 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b25c19f49ef294865462bf741e0430c59295ac15;p=linux-block.git btrfs: handle invalid profile in chunk allocation Do not BUG_ON() when an invalid profile is passed to __btrfs_alloc_chunk(). Instead return -EINVAL with ASSERT() to catch a bug in the development stage. Suggested-by: Johannes Thumshirn Reviewed-by: Johannes Thumshirn Reviewed-by: Josef Bacik Signed-off-by: Naohiro Aota Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3d35466f34b0..f1c98b01f6ec 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4773,7 +4773,10 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, int j; int index; - BUG_ON(!alloc_profile_is_valid(type, 0)); + if (!alloc_profile_is_valid(type, 0)) { + ASSERT(0); + return -EINVAL; + } if (list_empty(&fs_devices->alloc_list)) { if (btrfs_test_opt(info, ENOSPC_DEBUG))