Unverified Commit 86987d26 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12428 jfs: check if leafidx greater than num leaves per dmap tree

parents 74d13ba5 0c66ebbb
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -2944,9 +2944,10 @@ static void dbAdjTree(dmtree_t *tp, int leafno, int newval, bool is_ctl)
static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
{
	int ti, n = 0, k, x = 0;
	int max_size;
	int max_size, max_idx;

	max_size = is_ctl ? CTLTREESIZE : TREESIZE;
	max_idx = is_ctl ? LPERCTL : LPERDMAP;

	/* first check the root of the tree to see if there is
	 * sufficient free space.
@@ -2978,6 +2979,8 @@ static int dbFindLeaf(dmtree_t *tp, int l2nb, int *leafidx, bool is_ctl)
		 */
		assert(n < 4);
	}
	if (le32_to_cpu(tp->dmt_leafidx) >= max_idx)
		return -ENOSPC;

	/* set the return to the leftmost leaf describing sufficient
	 * free space.