bcachefs: Don't overflow stack in bch2_extent_merge_inline()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2019-05-29 20:06:06 -04:00 committed by Kent Overstreet
parent 5884fddfe7
commit 1ae9733456
2 changed files with 5 additions and 4 deletions

View file

@ -41,10 +41,7 @@ struct bkey_s {
#define bkey_next(_k) vstruct_next(_k)
static inline unsigned bkey_val_u64s(const struct bkey *k)
{
return k->u64s - BKEY_U64s;
}
#define bkey_val_u64s(_k) ((_k)->u64s - BKEY_U64s)
static inline size_t bkey_val_bytes(const struct bkey *k)
{

View file

@ -1651,6 +1651,10 @@ static bool bch2_extent_merge_inline(struct bch_fs *c,
EBUG_ON(bkey_written(b, m));
if (bkey_val_u64s(l) > BKEY_EXTENT_VAL_U64s_MAX ||
bkey_val_u64s(r) > BKEY_EXTENT_VAL_U64s_MAX)
return BCH_MERGE_NOMERGE;
/*
* We need to save copies of both l and r, because we might get a
* partial merge (which modifies both) and then fails to repack