Commit 6bdc51d8 authored by Jens Axboe's avatar Jens Axboe Committed by Li Nan
Browse files

block: add a BUILD_BUG_ON() for adding more bio flags than we have space

mainline inclusion
from mainline-v6.3-rc1
commit a3df2e45
bugzilla: https://gitee.com/openeuler/kernel/issues/IB7FJU

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=a3df2e456c0f9db4cc7f2013eb0beb853945b937



--------------------------------

We have BIO_FLAG_LAST in the enum for bio specific flags, but it's
not used to check that we're not exceeding the size of them. Add
such a check.

Reviewed-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>

Conflicts:
  block/bio.c
[Commit 49d1ec85 ("block: manage bio slab cache by xarray") remove
bio_slabs/bio_slab_nr/bio_slab_max.]
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
Signed-off-by: default avatarLi Nan <linan122@huawei.com>
parent 958384da
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1628,6 +1628,8 @@ static int __init init_bio(void)
	if (!bio_slabs)
		panic("bio: can't allocate bios\n");

	BUILD_BUG_ON(BIO_FLAG_LAST > 8 * sizeof_field(struct bio, bi_flags));

	bio_integrity_init();

	for (i = 0; i < ARRAY_SIZE(bvec_slabs); i++) {